Does Ubuntu support "@reboot" in crontab?
Does Ubuntu support @reboot
in crontab?
I find documentation suggesting it is supported, but web chatter asserts it is not.
I cannot make the @reboot
section work.
The "after midnight" section works fine.
Here is the test example from my /etc/crontab
:
$ cat /etc/crontab
# /etc/crontab: system-wide crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
##
# in the beginning -
@reboot /var/kiosk/btest.sh
# after midnight
30 0 * * * root /etc/cron.daily/kiosk/kioskReboot.sh
# end of crontab
shell script btest.sh
#!/bin/bash
date > /var/kiosk/STARTFLAG.txt
echo we booted >> /var/kiosk/STARTFLAG.txt
date
echo we booted
permissions
$ ls -l btest.sh
-rwxrwxrwx 1 root root 147 Aug 21 15:19 btest.sh
$ ls -ld
drwxrwxrwx 14 laptopsanytime root 4096 Aug 21 16:30 .
@reboot is supported in Ubuntu. The reason why your entry
@reboot /var/kiosk/btest.sh
doesn't work in /etc/crontab is because it's missing the user field. The correct syntax would be
@reboot root /var/kiosk/btest.sh
Ubuntu 16.04.5 LTS: As root:
crontab -e
Add the following lines:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@reboot /path_to_script.sh 2>&1 >> /path_to_log.log
2>&1 >> will output stdout to /path_to_log.log so you can troubleshoot this