(1)命令行输入crontab -ecentos
crontab -e
(2)输入a或者i能够进入编辑状态,可输入任务代码。代码格式能够进入/etc/crontab查看bash
[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/下面code
[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命令能够看到这个文件的内容就是前面编辑的内容。