<---- template headericclude ----->
my cron job stopped working
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2010
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    Join Date
    Oct 2011
    Posts
    1,917
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  3. #3
    Join Date
    Apr 2009
    Location
    central NY, USA
    Posts
    1,669
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    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.
    ---

  4. #4
    Join Date
    Nov 2008
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  5. #5
    Join Date
    Nov 2008
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  6. #6
    Join Date
    Feb 2010
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: my cron job stopped working

    Quote 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"?

  7. #7
    Join Date
    Feb 2010
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: my cron job stopped working

    Quote 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

  8. #8
    Join Date
    Nov 2008
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  9. #9
    Join Date
    Feb 2010
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  10. #10
    Join Date
    Feb 2010
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  1. cron not working
    By JAScarb in forum Using Fedora
    Replies: 31
    Last Post: 26th May 2015, 09:24 PM
  2. fwbackups cron job not working
    By johnandrews2332 in forum Using Fedora
    Replies: 1
    Last Post: 3rd April 2015, 02:43 PM
  3. Replies: 0
    Last Post: 16th November 2010, 02:58 PM
  4. Fedora 9 - Cron jobs stopped running
    By ikmyer in forum Using Fedora
    Replies: 3
    Last Post: 7th October 2008, 01:11 PM
  5. Cron is not working, please help!
    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
  •  
[[template footer(Guest)]]