Cronjobs not executing for user (f37)

For some reason a cronjob-- the first and only for any regular user on this system-- is not being executed.

crond is running, ascertained by “ps -ef” and “systemctr status crond.service”

/etc/cron.deny is empty
Put the username into /etc/cron.allow and did “systemctl restart crond.service”

Ran the command segment of the crontab entry and it worked just as expected. But it doesn’t run from cron.

I thought to look at the error logs, but I don’t know where they are… not in /var/log/.

I’ve set up cron successfully many times over the years, never had such trouble. Help! (Thanks)

Searching for error logs, I tried this:

journalctl -u cron.service

– No entries –

Here’s the whole crontab file:

$ crontab -l
#min	hr	DayofMonth	Month	DayofWk		cmd
*	*	*		*	*		/usr/bin/date +"%R" >> /home/user1/cron.out

This should be crond.service

2 Likes

Keep in mind that cron is a legacy method, while the recommended way is systemd timers:

2 Likes

Thanks! You’re right. Works much better. :grinning:

Now I see that the user1 crontab is being read by crond. But no error is reported.

Thanks, @vgaetera . I’ll take a look at that… later. I’ve got a big crontab I want to install and have running. Some day I’ll switch over to the new way.

Found the problem. For some reason date +“%R” isn’t executing properly within cron. It works fine at the commandline. I changed that to simply “date” and then I got the output. Has to be that cron is mangling the +“%R” for some reason.

I tested your theory and it certainly seems the formatting does not get processed when date is called by cron.
What I also tested was writing a simple script to process the date command you wished, then used cron to call that script. In that way it seems to work as you expected and the output is formatted.
The content of the script is simply

#!/bin/bash
/usr/bin/date '+%R' >> /home/USER/cron.out
1 Like

Thanks, @computersavvy that’s always a good alternative.

I played around with the crontab entry and found that cron was horking on the ambersand (&) and so if I backslash-escaped it, it worked as it should. I.e.,

/usr/bin/date “+%R” >> … (there’s supposed to a backslash character right before the percent-sign, but the web software displaying this page isn’t displaying it :smiley: )

It’s kinda messed up that the bash code works in a script, but not in a crontab. I don’t understand why cron can’t handle the ambersand.

Another thing: Why is there no error reported in journalctl under crond when cron is obviously horking on something?

Mysteries, mysteries…

1 Like

Ampersand & or percent %?

% is a special character meaning newline in crontab. See man crontab.5 about the crontab file format (not to be confused with man crontab which defaults to section 1, about the crontab program)

1 Like

@jn64, you’re right, it’s the percent. Thanks for the catch.

1 Like