linux crontab命令用法
来源:互联网 发布:如何用微博推广淘宝 编辑:程序博客网 时间:2024/06/05 02:33
crontab命令是linux提供的配置定时任务的工具
crontab -l:查看现有定时任务
crontab -e:编辑定时任务
格式
* * * * * command
分 时 日 月 周 命令
第1列表示分钟1~59 每分钟用*或者 */1表示,*/10表示每10分钟
第2列表示小时1~23(0表示0点)
第3列表示日期1~31
第4列表示月份1~12
第5列标识号星期0~6(0表示星期天)
第6列要运行的命令
*:(星号)表示所有的值,如 ,* 16 5 6 *,表示6月5日16点到17点之间的每一分钟执行一次
,:(逗号)表示可选的值,如,3,4,5 16 5 6 *,表示6月5日16点3分,4分,5分各执行一次
-:(中划线)表示范围,如5-10 16 5 6 *,表示6月5日16点5分到10分,每分钟执行异常
/:(正斜杠)表示频率,如*/10 * * * *,表示每十分钟执行一次
crontab用户权限问题
Linux 下可以通过创建文件 /etc/cron.allow 或者 /etc/cron.deny 来控制权限:
/etc/cron.allow 文件存在,那么只有这个文件中列出的用户可以使用 crontab, 同时 /etc/cron.deny文件被忽略;
/etc/cron.allow 文件不存在,那么文件 /cron.deny 中列出的用户
将不能用使用 crontab
下面这种情况用户lxm没有crontab权限
[root@localhost etc]# cat /etc/cron.denylxm[root@localhost etc]# cat /etc/cron.allow[root@localhost etc]# [lxm@localhost ~]$ crontab -lYou (lxm) are not allowed to use this program (crontab)See crontab(1) for more information
将用户加入cron.allow后,用户lxm有了crontab权限
[root@localhost etc]# cat /etc/cron.allowlxm[lxm@localhost ~]$ crontab -lno crontab for lxm
crontab服务启动与停止
[root@localhost etc]# service crond statuscrond (pid 1343) is running...[root@localhost etc]# service crond stopStopping crond: [ OK ][root@localhost etc]# service crond startStarting crond: [ OK ][root@localhost etc]# service crond restartStopping crond: [ OK ]Starting crond: [ OK ]
crontab用户存放目录/var/spool/cron
[root@localhost etc]# ll /var/spool/crontotal 4-rw-------. 1 lxm lxm 72 Jul 11 18:54 lxm
0 0
- linux crontab命令用法
- linux crontab命令用法
- Linux crontab 命令用法
- linux crontab 命令的用法
- Linux下crontab命令的用法:sudo crontab -l
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- Linux下crontab命令的用法
- ARM-linux汇编常用语法
- 非递归的归并排序
- C语言动态数组原理及实现
- 【SSH视频】--- spring中的事务和hibernate中的session应用
- Jmeter测试Java请求示例
- linux crontab命令用法
- IONIC----02.ionicBackdrop
- android中Context的作用
- HDOJ 4861 Couple doubi
- Ne10开源库
- css3背景
- Java查看动态代理生成的代码 in Action
- eclipse c++ 问题Launch failed,Binary not found和A program file was not specified in the launch configur
- kmeans()和partition()对自己的数据聚类