Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following script to update file based on MD5 comparison, script works perfectly from command line but when i put it in cron nothing happens. I only have root user on the system, script is owned by root, in crontab am calling the script like this: /bin/bash /home/papa/systems/

Here is my script, I have tried all the solutions I have read till now but no progress, please help.






#echo generating MD5 for $FILE_TO_CHECK  

echo `md5sum $FILE_TO_CHECK` > $MD5FILENEW

if [ -z "$MD5PRINT" ]; then
    echo "ERROR Recived an empty MD5PRINT thats not valid, aborting"
    exit 1



if [ -z "$OLDMD5PRINT" ]; then
    echo "Got an empty string from the oldfile, aborting"
    echo $OLDMD5PRINT 
    exit 1

if [ "$OLDMD5PRINT" != "$MD5PRINT" ]; then 
    echo "File has changed"
    echo "updating MD5 file...."
    echo $MD5PRINT > $MD5FILE
    echo "file content:"
    cat $MD5FILE
    echo `date` >> /home/log
    echo done
    echo nothing >> /home/log
share|improve this question
what does your crontab look like? – Zypher Oct 31 '11 at 22:00
*/1 * * * * /bin/bash /home/papa/systems/ – APZ Oct 31 '11 at 22:01
Can you run /bin/bash /home/papa/systems/ in the shell? – mr-euro Oct 31 '11 at 22:02
yes it works perfectly from comand line – APZ Oct 31 '11 at 22:02
Try adding MAILTO=root at the top of the crontab and see if you get any error messages – Zypher Oct 31 '11 at 22:03

Try adding >/home/papa/systems/sron.log 2>&1 to the end of line in crontab and watch log to understand what is happening. The most probable reason is that script is not run at all, for example because of error pointed in lain's answer

share|improve this answer

This works fine on a CentOS system I have to hand from a user crontab (crontab -e). Did you put this in root's crontab or did you put it in /etc/crontab (or similar)? If you did then you need to specify your crontab as

*/1 * * * * root /bin/bash /home/papa/systems/
share|improve this answer
I believe */1 is extraneous; if you just use a star it should run every minute. – Handyman5 Nov 1 '11 at 17:21
@Handyman5: yep, I was using syntax consistent with the OP's - see his comment above. – Iain Nov 1 '11 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.