Cron @reboot execute command on system start like rc.local

Everyone knows that crontab entries look like this:

* * * * * /usr/local/bin/my-script

Which will execute command “my-script” every minute.

There are other specific entries that can prove useful: @annually, @monthly, @daily, @midnight and the best of them all @reboot.

@reboot /usr/local/bin/my-script

This will execute command “my-script” every time system starts (reboot or shutdown) with environment variables, ownership and permissions of the user with this crontab entry.


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.