Writing a scheduled task is like CRONTAB-E, but what's the difference between this and direct Vim/etc/crontab? Why did you finish the planning task,/etc/crontab?
Method 1: Use the command crontab-e and edit the timed script directly.
After this execution, the user-defined, will be written to the/var/spool/cron directory, generate a file with the user name consistent with the file content is our editor's timed script.
[Email protected] ~]# crontab-l
0 */1 * * */root/mailjiankong.sh
*/5 * * * */root/2.sh
0 * * * */root/3.sh
0 * * */root/4.sh
0 */1 * * */usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
[Email protected] ~]#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Method 2:
Edit the timed script using the command vi/etc/crontab.
[Email protected] ~]# Cat/etc/crontab
Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
home=/
# for details see Mans 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
[Email protected] ~]#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Approximate differences:
1, Crontab will be a grammar check, Vi/vim will not.
2, CRONTAB-E is the user level, and Vim/etc/crontab is the system level.
3, CRONTAB-E is a user's cycle planning task;/etc/crontab is the periodic task of the system.
4, no matter with crontab-e or change/etc/crontab do not need to restart Crond service.
Recommendation: Crontab generally enough to meet the needs, but also check the syntax, compare recommended use!
This article from "Ningzhiyuan @it share" blog, reproduced please contact the author!
The difference between crontab-e and direct editing/etc/crontab!