Cron help please

#1

Could do with some help with crontab and although I have looked around this and other forums I have not had any success. I have a very basic script that runs from bash. it loads a playlist and plays track 4. when I add it to crontab /etc/crontab using @reboot root /bin/sh [file path] it does not work.
Any ideas?

as an addition

22 * * * * root /bin/sh [file path] does work so it might be that @reboot is the problem.

0 Likes

#2

I have a feeling it might be better in startup.sh, make a backup copy first though.
sudo nano /opt/musicbox/startup.sh
place it at the end after the autoplay setup bit, or amend the autoplay setup bit, have a look here for some help with that.
It’s a while since I used cron, I think it fails it’s because it tries to play it before musicbox is ready, then gives up, the alternative is to ask it to sleep for a while, however I didn’t find that very successful.

0 Likes

#3

Thanks for the reply, the script will also hold the setup for the gpio pins etc so I was looking for a way of getting cron to do that. Ill let you know how I get on.

I have done some more tests and cannot get @reboot to do anything at all. I can get cron to make directories every minuet but cannot get it to do it on start up. could someone else see if this replicates on other systems.

more update:

@ reboot was not running because /var/run/crond.reboot was not being removed from boot to boot, as such @reboot was ignored. Removing the file after a reboot allows @reboot to run. So the last thing to do in my gpio setup script is now to remove /var/run/crond.reboot

0 Likes