Topic
3 replies Latest Post - ‏2012-05-21T12:48:12Z by SystemAdmin
SystemAdmin
SystemAdmin
1143 Posts
ACCEPTED ANSWER

Pinned topic crontab not updating the file

‏2012-05-20T15:22:43Z |
Hi Thomas,

In crontab under unix i have added the following line to run a shell script every minute:
  • * * * * /usr/ahy/tst.sh
But it is not working!
Could you please advise what is wrong with it?

Please note if i added the following line:
  • * * * * /usr/ahy/tst.sh > * * * * * /usr/ahy/tst.log
Then the tst.log is getting updated every minute but with 0 bytes (empty file)

WBR,
Ahmed
Updated on 2012-05-21T12:48:12Z at 2012-05-21T12:48:12Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1143 Posts
    ACCEPTED ANSWER

    Re: crontab not updating the file

    ‏2012-05-21T07:58:29Z  in response to SystemAdmin
    Hi Ahmed,
    the fact the tst.log file is getting updated (i suppose its access/modification time is changing if not the content) suggests the script is running as scheduled. The fact 0 bytes are written to the log could mean the script is putting its output to stderr (you have only the stdout redirected to the tst.log file). So you might try to change the crontab setting to
    * * * * * /usr/ahy/tst.sh 2>&1 > /usr/ahy/tst.log

    and see if anything is put into the log file.

    Rgds, Tomas
    • SystemAdmin
      SystemAdmin
      1143 Posts
      ACCEPTED ANSWER

      Re: crontab not updating the file

      ‏2012-05-21T12:14:38Z  in response to SystemAdmin
      Hi Tomas,
      I have added 2>&1 but still the same, moreover the time of the file tst.log is not getting updated this time.

      As you mentioned below the time of the file tst.log is getting updated but not the content.

      One more thing i did not mention, the time of the file tst.sh is not getting updated this means the crontab is not reading the tst.sh at all!

      Kindly advise!

      WBR,
      Ahmed
      • SystemAdmin
        SystemAdmin
        1143 Posts
        ACCEPTED ANSWER

        Re: crontab not updating the file

        ‏2012-05-21T12:48:12Z  in response to SystemAdmin
        Hi Ahmed,
        what kind of unix do you use? It's some GNU Linux based distribution or some of the commercial clones (AIX, HP-UX, ....)?
        I'd suggest to consult your OS documentation - the access to crontab functions is often drived by existence/content of cron.allow and/or cron.deny files and each of the *nix clones might have its own default setting. Also, some of the implementations might not accept the new content of the crontab file if it's edited manually and need the 'crontab -e' tool to be used.
        The cron events should also be logged into the /var/log/syslog (or wherever your syslog file is) so might to check it.

        HTH, Tomas