You are reading a single comment by @useless and its replies. Click here to read the full conversation.
  • Cheers all for the assistance.

    It looks like I have a few issues. First one is that the full command wasn't being executed for some reason so however I tried to log it I wasn't getting any output. The command actually being executed was this :

    Oct  2 13:50:01 raspberrypi CRON[5184]: (root) CMD (sh /home/pi/bkup_rpimage/bkup_rpimage.sh start -c /media/Raspi/Backup/$(date +)
    

    Should stuff be in quotes or something? I've not seen any reference to that before.

    When I shorten down the output so the command does run I get the following error in my log file

    /home/pi/bkup_rpimage/bkup_rpimage.sh: 299: /home/pi/bkup_rpimage/bkup_rpimage.sh: blockdev: not found
    /home/pi/bkup_rpimage/bkup_rpimage.sh: 300: /home/pi/bkup_rpimage/bkup_rpimage.sh: blockdev: not found
    /home/pi/bkup_rpimage/bkup_rpimage.sh: 352: /home/pi/bkup_rpimage/bkup_rpimage.sh: losetup: not found
    /home/pi/bkup_rpimage/bkup_rpimage.sh: 360: /home/pi/bkup_rpimage/bkup_rpimage.sh: losetup: not found
    -e Required program losetup is not installed
    

    Not sure why it runs when I run it directly but not using cron. I can't find any reference to it from googling the script.

  • Scripts run from cron aren't inheriting your interactive shell setup, and often have a different PATH. You can find the absolute path of each of the programs it's complaining about by typing eg.

    $ which blockdev

    in your shell, and then use the result (/sbin/blockdev or whatever it happens to be) explicitly in the script. Or just add that directory to PATH inside the script.

About

Avatar for useless @useless started