方法一:在系統上建立systemctl服務,經過systemctl status | start | restart | disable | enable autoRun.service方式自啓服務ide
一、在/etc/systemd/system下建立autoRun.service文件url
二、編輯autoRun.service文件rest
/etc/systemd/system/autoRun.servicecrontab
[root@bogon system]# cat auto_run_script.service ip
[Unit] get
Description=Run a Custom Script at Startup string
After=default.target it
[Service] io
ExecStart=/opt/project/autoRunScript.shclass
[Install]
WantedBy=default.target
[root@bogon system]#
三、從新加載配置文件
systemctl daemon-reload
systemctl enable autoRun.service
方法二:使用crontab特殊計劃任務
crontab -e
@reboot /opt/project/autoRun.sh
特殊計劃任務寫法補充
string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".