Normal cron jobs (not using the @
symbol) run just fine.
For testing purposes, I have set up a command to be run echo "hi" > /home/kasperfred/reboot.txt
which works when running from terminal, and using running as a normal cronjob with the crontab command:
* * * * * echo "hi" > /home/kasperfred/reboot.txt
But the following command doesn't work:
@reboot echo "hi" > /home/kasperfred/reboot.txt
When using sudo reboot
to reboot, no reboot.txt is written, however, syslog logs the command as successfully run.
From syslog:
Jun 11 14:30:03 zeus cron[2224]: (CRON) INFO (pidfile fd = 3)
Jun 11 14:30:03 zeus cron[2224]: (CRON) INFO (Running @reboot jobs)
Jun 11 14:30:03 zeus CRON[2266]: (kasperfred) CMD (echo "hi" > /home/kasperfred/reboot.txt)
What am I doing wrong, and if this cannot be solved, what alternatives are there for running scripts at boot time?
I'm using Ubuntu Server 16.04 LTS.
/tmp/reboot.txt
instead? – steeldriver Jun 11 '17 at 13:01@reboot
. However, this doesn't quite explain the initial problem; namely why it doesn't launch the jupyter notebook server when it works in terminal (the notebook-dir is not encrypted) – Jun 11 '17 at 13:29cron
does not provide a suitable environment, or that other services on which the program depends are not started or are not yet ready - probably the right way to do it is to create asystemd
service – steeldriver Jun 11 '17 at 13:40crontab -e
command or you set it in/etc/cron.d/
? – Bahram Jul 19 '17 at 04:16crontab -e
– Jul 20 '17 at 18:17@reboot
. For example: https://askubuntu.com/a/970795/566421 – pa4080 Nov 01 '17 at 18:48