-
24th March 2017, 12:47 PM
#1
my cron job stopped working
Hi All,
I need a second pair of eyes here. Can you guys see anything wrong here:
# grep CimCheck /etc/crontab
01,11,21,31,41,51 03-23 * * * root /home/linuxutil/CimCheck.pl6
# ls -al /home/linuxutil/CimCheck.pl6
-rwxr-x---. 1 root root 8493 Mar 24 04:27 /home/linuxutil/CimCheck.pl6
# tail /var/log/cron
Mar 24 04:01:01 server CROND[920]: (root) CMD (/home/linuxutil/CimCheck.pl6)
Mar 24 04:01:01 server run-parts[919]: (/etc/cron.hourly) starting 0anacron
Mar 24 04:01:01 server run-parts[919]: (/etc/cron.hourly) finished 0anacron
Mar 24 04:05:01 server CROND[5177]: (root) CMD (/usr/sbin/ntpdate time.nist.gov)
Mar 24 04:11:01 server CROND[9537]: (root) CMD (/home/linuxutil/CimCheck.pl6)
Mar 24 04:20:01 server CROND[13758]: (root) CMD (/bin/netstat -i | logger -p user.notice -t netstat)
Mar 24 04:21:01 server CROND[13769]: (root) CMD (/home/linuxutil/CimCheck.pl6)
Mar 24 04:31:01 server CROND[18052]: (root) CMD (/home/linuxutil/CimCheck.pl6)
Mar 24 04:41:01 server CROND[22292]: (root) CMD (/home/linuxutil/CimCheck.pl6)
Mar 24 04:51:01 server CROND[26664]: (root) CMD (/home/linuxutil/CimCheck.pl6)
The program creates a log file that shows every time it is called. The log is only showing when I call it manually. This started about two weeks ago. It was working before then. Are my file permission wrong?
I am stumped.
-T
Last edited by ToddAndMargo; 24th March 2017 at 01:00 PM.
-
24th March 2017, 01:44 PM
#2
Re: my cron job stopped working
Check for executable bit and a proper shebang if it is a script.
Also, users home directories under /home are usually denied access to anything other then user. Not sure if that affects cronjob daemon also though.
-
24th March 2017, 02:59 PM
#3
Re: my cron job stopped working
did you edit the /etc/crontab back then? If so, and depending on the chosen editor, you may have to:
Code:
sudo chmod 644 /etc/crontab;sudo restorecon /etc/crontab;sudo systemctl restart crond
I use emacs and therefore have to run that every time I edit it.
Hope it helps.
---
-
24th March 2017, 06:01 PM
#4
Re: my cron job stopped working
Does the journal show anything useful? I wonder if a system update finally pulled the plug on using /etc/crontab - it seems to have been depreciated. Apparently the preferred alternative is to place a job in the /etc/cron.d directory, or use a user crontab, if /etc/anacrontab won't do.
-
24th March 2017, 07:24 PM
#5
Re: my cron job stopped working
I more or less replicated your situation (using /etc/crontab), and in the journal I'm getting a "ERROR (getpwnam() failed)" from crond, for root executing a user file, and also for root executing a root file. I also tried to implement my suggestion for using /etc/cron.d, and now I've mangled the SELinux for /etc/crontab - and apparently also stumbled across a bug in the SELinux Troubleshooter. So, ... forget I said anything. However, maybe you're also getting that "ERROR getpwnam() failed"?
Additional note:
* * * * * root touch /tmp/file
works fine in /etc/crontab and also in /etc/cron.d/TEST. It was a "nice run-parts ..." that gave the above error. "nice run-parts ..." is working fine in /etc/anacrontab and also in a user crontab - just not in /etc/crontab, for some reason.
Last edited by dswaner; 24th March 2017 at 08:09 PM.
Reason: Add additional note
-
24th March 2017, 09:23 PM
#6
Re: my cron job stopped working
Originally Posted by
srakitnican
Check for executable bit and a proper shebang if it is a script.
Also, users home directories under /home are usually denied access to anything other then user. Not sure if that affects cronjob daemon also though.
what is a "shebang"?
-
24th March 2017, 09:58 PM
#7
Re: my cron job stopped working
Originally Posted by
dswaner
I more or less replicated your situation (using /etc/crontab), and in the journal I'm getting a "ERROR (getpwnam() failed)" from crond, for root executing a user file, and also for root executing a root file. I also tried to implement my suggestion for using /etc/cron.d, and now I've mangled the SELinux for /etc/crontab - and apparently also stumbled across a bug in the SELinux Troubleshooter. So, ... forget I said anything. However, maybe you're also getting that "ERROR getpwnam() failed"?
Additional note:
* * * * * root touch /tmp/file
works fine in /etc/crontab and also in /etc/cron.d/TEST. It was a "nice run-parts ..." that gave the above error. "nice run-parts ..." is working fine in /etc/anacrontab and also in a user crontab - just not in /etc/crontab, for some reason.
I am trying calling it in /tmp to see what happens. The backup program is also in /home/linuxutil and it is running fine (it eMail me the results).
I also tried 2777 and that did not work either.
/var/mail has no entry for root, so no error to looks at there.
Edit: nope, running from /tmp did not work either
My backup programs is running fine from /home/linuxutil (it emails me the the result) and it is running from the same /etc/crontab
Last edited by ToddAndMargo; 24th March 2017 at 10:05 PM.
Reason: new info
-
24th March 2017, 11:21 PM
#8
Re: my cron job stopped working
/etc/crontab is now working fine for me. The "ERROR getpwnam() failed" was caused by the omission of the user-id on the crontab line, so it was trying to validate a user "nice". (The user-id is not used in a user crontab, which is what I usually do.)
A shebang is a "#!" at the start of the first line of a script, which shows which program should execute the script. For example,
#!/usr/bin/rexx
as the first line, would cause the rest of the script to be processed by the /usr/bin/rexx command. That works almost everywhere, but for example, does NOT work if the script is executed by the "at" command, which ignores the shebang and always runs the script with the /bin/sh shell.
-
25th March 2017, 12:19 AM
#9
Re: my cron job stopped working
Okay, I narrowed it down to my program. I substituted a Perl program that writes to a similar log and it is working fine. So, now the plot thickens!
-
25th March 2017, 12:24 AM
#10
Re: my cron job stopped working
AH HA!!!!
These guys are the culprit:
<code>
use Terminal::ANSIColor;
sub PrintRed ( $Str ) { print color('bold'), color('red'), "$Str", color('reset'); }
sub PrintGreen ( $Str ) { print color('bold'), color('green'), "$Str", color('reset'); }
sub PrintBlue ( $Str ) { print color('bold'), color('blue'), "$Str", color('reset'); }
</code>
So now I will figure out how to check to see if I am running from a terminal or crontab.
Thank you all for the second pair of eyes! Very much appreciated!
-T
Similar Threads
-
By JAScarb in forum Using Fedora
Replies: 31
Last Post: 26th May 2015, 09:24 PM
-
By johnandrews2332 in forum Using Fedora
Replies: 1
Last Post: 3rd April 2015, 02:43 PM
-
By THEcreationist in forum Hardware
Replies: 0
Last Post: 16th November 2010, 02:58 PM
-
By ikmyer in forum Using Fedora
Replies: 3
Last Post: 7th October 2008, 01:11 PM
-
By kosh in forum Using Fedora
Replies: 10
Last Post: 1st August 2007, 01:46 PM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
[[template footer(Guest)]]