CentOS 定时任务文件保存及查看地方
首页 专栏 centos 文章详情
0

CentOS 定时任务文件保存及查看地方

jrue 发布于 5 月 19 日

一、创建一个任务文件

(1)命令行输入crontab -e

crontab -e

(2)输入a或者i可以进入编辑状态,可输入任务代码。代码格式可以进入/etc/crontab查看

[root@VM-0-10-centos cron]# cat /etc/crontab # 输出结果 SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed

二、保存文件

先按Esc键,然后输入“:wq”

三、查看文件

保存成功的文件去哪里了呢?在/var/spool/cron/下面

[root@VM-0-10-centos cron]# cd /var/spool/cron [root@VM-0-10-centos cron]# ll total 4 -rw------- 1 root root 176 May 19 14:17 root
这里可以看到一个root文件,因为我用的root账号登录,所以生成了一个root文件。
通过cat命令可以看到这个文件的内容就是前面编辑的内容。
crontab centos 定时任务
阅读 24 发布于 5 月 19 日
举报
收藏
分享
本作品系原创, 采用《署名-非商业性使用-禁止演绎 4.0 国际》许可协议
jrue

努力可以改变能力

202 声望
4 粉丝
关注作者
0 条评论
得票数 最新
提交评论
jrue

努力可以改变能力

202 声望
4 粉丝
关注作者
宣传栏
目录

一、创建一个任务文件

(1)命令行输入crontab -e

crontab -e

(2)输入a或者i可以进入编辑状态,可输入任务代码。代码格式可以进入/etc/crontab查看

[root@VM-0-10-centos cron]# cat /etc/crontab # 输出结果 SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed

二、保存文件

先按Esc键,然后输入“:wq”

三、查看文件

保存成功的文件去哪里了呢?在/var/spool/cron/下面

[root@VM-0-10-centos cron]# cd /var/spool/cron [root@VM-0-10-centos cron]# ll total 4 -rw------- 1 root root 176 May 19 14:17 root
这里可以看到一个root文件,因为我用的root账号登录,所以生成了一个root文件。
通过cat命令可以看到这个文件的内容就是前面编辑的内容。