Skip to content
Advertisement

Crontab not starting command on reboot

I need a command to run at reboot. This command is called script.sh

JavaScript

This command pipes input to a python program I wrote called test.py.

JavaScript

The problem is the program is not running when I check the processes.The syslog file states that it started the command on reboot, but it is not running.

JavaScript

my crontab entry looks like this

JavaScript

Is the problem with cron or with my program? My program works fine when run from the command line, but not when executed by cron.

Advertisement

Answer

Quite often, if something runs fine from the command line but not as a cron job, it’s because the PATH is set differently for cron jobs. The PATH is set quite conservatively to make sure that the wrong thing doesn’t get run, which would cause security issues.

You could start by putting the full path to the ibeacon program in the shell script (i.e., run it as

JavaScript

rather than just

JavaScript

The script is also being run as root, so if ibeacon is in your own bin directory, it won’t be found without the full path.

Advertisement