Linux Execute Cron Job After System Reboot

To execute a cron job after system reboot on Linux, you can add a cron job to the root crontab that runs at reboot.

Here are the steps to create a cron job to run after system reboot:

  1. Open the root crontab file for editing using your preferred text editor. You can use the following command to open the crontab file in the vi editor:
    sudo crontab -e
  2. Add the following line to the crontab file:
    @reboot /path/to/your/script

    Replace /path/to/your/script with the path to your script that you want to run after system reboot.

  3. Save the changes to the crontab file and exit the editor.

The cron job will now run your script after the system reboots. You can check the logs to confirm that your script has run successfully.

Leave a Comment