Thứ Hai, 2 tháng 10, 2017

How to Auto Execute Commands/Scripts During Reboot or Startup

Method #1 – Use a cron Job

Besides the usual format (minute / hour / day of month / month / day of week) that is widely used to indicate a schedule, cron scheduler also allows the use of @reboot. This directive, followed by the absolute path to the script, will cause it to run when the machine boots.

Method #2 – Use /etc/rc.d/rc.local

This method is valid even for systemd-based distributions. In order for this method to work, you must grant execute permissions to /etc/rc.d/rc.local as follows:
# chmod +x /etc/rc.d/rc.local
and add your script at the bottom of the file.


Share This!


Không có nhận xét nào:

Đăng nhận xét