Search code examples
linuxbashcronrhel

Running bash script 10 minutes after the system start


I'm trying to run a bash script 10 minutes after my system startup and on every reboot. I was planning to the @reboot of crontab, but I'm not sure of two things

  • Whether it will run on the first system start or only on reboot.
  • How to delay the run by 10 minutes after the reboot.

What expression would suit my situation the best? Please note that I can't run 'at' or system timer to accomplish this as both are not accessible to us. I'm working on the RHEL 7..


Solution

  • I think your question may be more appropriate on the Unix and Linux stack exchange, because I found two answers over there which directly address your question:

    https://unix.stackexchange.com/questions/57852/crontab-job-start-1-min-after-reboot

    Basically you can always just add sleep 600 to the beginning of your cronjob invocation.

    As to whether you should be running a cronjob vs an init script:

    https://unix.stackexchange.com/questions/188042/running-a-script-during-booting-startup-init-d-vs-cron-reboot

    There are a handful of subtle differences, but basically, your cron @reboot will run each time the system starts and may be more easy to manage as a non-root user.