开机自启方法一:
1)cd /etc/rc.d/rc.local
2)shell脚本目录添加到文件末尾(提前确认文件可执行)
3)重启后就会执行开机自启
开机自启方法二:
1)cp /root/sh01.sh /etc/init.d/ # /root/sh01.sh为脚本文件目录
sh01.sh内容 :ntpdate cn.ntp.org.cn (全球ntp服务器)
2)chkconfig --add /etc/init.d/sh01.sh
定时任务
1)查看定时任务的状态
systemctl status crond.service
2)进入编辑用户的任务列表
crontab -e
3)查看任务列表
crontab -l
* * * * * command
| | | | | 命令
| | | | 周
| | | 月
| | 日
| 时
分
3,15 8-11 */2 * * myCommand 每隔两天的上午8-11点的第3分和15分执行任务
*表示任意时间
-表示区间,是一个范围
,分割时段
/n 分割,每隔多长时间执行一次