How to run cron job as soon as system reboot

I need to run a script called /root/scripts/ at every system boot. This is RHEL 7 server. How do I execute a cron job automatically at boot?

We can run a cron job at every system boot. You have to add a config option called @reboot to the task or crontab job. The job defined by @reboot level config option runs at RHEL or any Linux/Unix startup immediately after Linux reboots.

Executing a cron job automatically at Linux boot tim

  1. Run the crontab -e command
  2. Add the job to the @reboot.
  3. Make sure you use the full path to Linux script or command. For example:
    @reboot /root/scripts/
  4. Save and close the file.
  5. Now job will run at the Linux boot time.
1 Like

Do check up our help page:

1 Like

I tried out and rebooted test VM. It worked. Now I will do it on production because I can’t reboot prod RHEL 7 server.

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki