12

I searched this website and Google but couldn't find it.. How can I execute two (or more) commands using @reboot ?

What I have now:

@reboot /root/website1/starter.sh

What I want:

@reboot /root/website1/starter.sh
@reboot /root/website2/starter.sh

Is this correct or should I solve it otherwise?

Thanks in advance :)

Henry
  • 221

1 Answers1

12

Yes, that is the correct approach.

You could also reduce it to a single line, as such:

@reboot /root/website1/starter.sh && /root/website2/starter.sh

Just keep in mind that the scripts will run consecutively (not concurrently), and the second script will only run if the first script/command exits successfully. If the second script should run regardless of the result of the previous script, separate the commands with a semi-colon instead of &&.

If you need the scripts to run in parallel, you should stick with your original approach (one command/script on each line).

The double-ampersand (&&) can also be used in the "command" section to run multiple commands consecutively, but only if the previous command exits successfully. A string of commands joined by the double-ampersand will only get to the last command if all the previous commands are run successfully. If exit error-checking is not of a concern, string commands together, separated with a semi-colon (;)

CronHowto - Crontab Example

FastEthernet
  • 5,246