Is there any reason this cronjob would fail in cron, but not on the command line?

Posted by Treffynnon on Super User See other posts from Super User or by Treffynnon
Published on 2014-08-22T10:14:32Z Indexed on 2014/08/22 10:22 UTC
Read the original article Hit count: 209

Filed under:
|
|
|
|

I have written a little one liner that will email me when a list of files changes - I used sha512 to generate a list of hashes and then periodically check that those hashes still match.

*/5     *   *   *   *   /usr/bin/sha512sum --status -c /sha512.sumlist && echo "Success" > /dev/null || echo "Check robots.txt and index.html in /var/www as staging sites are now potentially exposed to the world and the damned googlebot" | /usr/bin/mail -s "Default staging server files have changed" [email protected]

It works fine on the command line with:

/usr/bin/sha512sum --status -c /sha512.sumlist && echo "Success" > /dev/null || echo "Check robots.txt and index.html in /var/www as staging sites are now potentially exposed to the world and the damned googlebot" | /usr/bin/mail -s "Default staging server files have changed" [email protected]

As soon as I run it as a cronjob though it emails every time it runs with the failure message instead of only when the sha512sum check should fail.

Is there something silly I have missed in a rush?

I forgot to mention that I am running an Ubuntu machine.

© Super User or respective owner

Related posts about linux

Related posts about ubuntu