My problem was that the crontab did not have a full environment. I made the script it was pointing to source my .bashrc
.
@reboot /home/user/www/example.com/bin/server
./server
does . /home/user/.bashrc
to get a working environment.
Domanda
I'm using @reboot ~/www/example.com/bin/server
in my user's crontab...but when I reboot the server, the web server (this script) does not come up. (script works fine from command line).
My guess is the /home/user
directory has not been mounted yet...does anyone know if its possible to get a script to run out of a home directory using this crontab @reboot
method?
Soluzione 3
My problem was that the crontab did not have a full environment. I made the script it was pointing to source my .bashrc
.
@reboot /home/user/www/example.com/bin/server
./server
does . /home/user/.bashrc
to get a working environment.
Altri suggerimenti
If you think /home/user hasn't been mounted (or some required systems aren't running) yet, in your crontab line, you can always wait before executing a command like:
@reboot sleep 60; /home/user/www/example.com/bin/server
It should definitely be due to the environment scenarios as given in comments. Try the following and check once by doing a reboot
@reboot (date > /tmp/date-check.txt)
To be sure cron is able to run the jobs.
In Ubuntu if you are using the Home Directory Encryption feature turned on then @reboot in your crontab file won't work as the file system is still encrypted when the system is starting up and cron runs its @reboot jobs.
Your options are to place your files in an unencrypted location (/usr/local/bin
or something?) or disable Home Directory encryption on your home directory.