前言
随着shell脚本的不断发展,shell学习这门技术也越来越重要,相信刚入行的人不太会编写shell的定时任务,下面按照步骤教你如何编写shell的定时任务
一、首先查看你的定时任务
crontab -l ##这个是查看你已经编写的定时任务命令
二、编写shell定时任务
1.打开shell定时任务编辑器
crontab -e
2.编写定时任务格式
代码如下(示例):
* * * * * /root/ckeck_mysql.sh 3996.166.3 3306
其中,五个星号分别代表 分钟、小时、日、月、星期(0-59, 0-23, 1-31, 1-12, 0-7),/root/ckeck_mysql.sh 是你要执行的脚本或命令,3996.166.3 3306 是可选的参数。
3.最后control的总命令情况
-u <user> define user
-e edit user's crontab
-l list user's crontab
-r delete user's crontab
-i prompt before deleting
-n <host> set host in cluster to run users' crontabs
-c get host in cluster to run users' crontabs
-s selinux context
-V print version and exit
-x <mask> enable debugging
总结
以上就是今天要讲的内容,本文仅仅简单介绍了shell定时任务的使用。