Description
1, Linux and Mac operating crontab are consistent
2, the configuration files are under/etc/crontab, if not created.
3. The test finds that the scheduled task created directly with the CRONTAB-E command is placed in the Temp folder, and the restart is deleted and is not associated with the/etc/crontab file.
Actual operation:
See if Crontab is started
sudo grep Cron
Check for required files
$ launchagents ll/etc/crontablsfile or directory #表示没有这个文件, you need to create a
Create a file
sudo Touch
Parameters of the Crontab
-u User: Used to set a user's crontab service;file: File is the name of the command, which indicates that file is thecrontab task list and loaded into crontab. If this file is not specified on the command line, the crontab command will accept the commands typed on the standard input (keyboard) and load them into crontab. -E: Edit the contents of a user's crontab file. If you do not specify a user, the crontab file for the current user is edited. -L: Displays the contents of a user's crontab file, or displays the contents of the current user's crontab file if no user is specified. -R:Deletes a user's crontab file from the/var/spool/cron directory and, if no user is specified, deletes the current user's crontab file by default. -I: Give a confirmation prompt when deleting a user's crontab file.
Eg: */1 * * * * /bin/date >> /User/Username(你的用户名)/time.txt
indicates the output of the current time to Time.txt per minute.
File formats for crontab
* 第1列分钟0~59 * 第2列小时0~23(0表示子夜) * 第3列日1~31 * 第4列月1~12 * 第5列星期0~7(0和7表示星期天) * 第6列要运行的命令
Crontab Service restart shutdown, open
Reference:
http://blog.csdn.net/zhenhanhong_tony/article/details/52658055
http://blog.csdn.net/zmzwll1314/article/details/52389967
http://blog.csdn.net/biyongyao/article/details/77791238 (the above content is transferred from this article)
http://blog.csdn.net/meixuesong/article/details/27481883
http://blog.csdn.net/lgt633744/article/details/45932035 (Alternative timing task implementation)
Use Crontab to implement timed tasks under Mac