Linux 系统定时任务则是由 cron (crond) 这个系统服务来控制的。用户可以使用crontab来创建自己的定时任务。
安装完成操作系统后,默认会安装此服务工具,并且会自动启动crond进程,crond进程每分钟会定期检查是否有要执行的任务,如果有则自动执行该任务。
使用 crontab 命令,我们可以在固定的间隔时间执行指定的系统指令或 shell 脚本。时间精确到分钟。一般用作日志分析和数据的定时备份。
命令参数:
usage: crontab [-u user] file
crontab [-u user] { -e | -l | -r }
-l:列出定时任务
-e:编辑定时任务
-r:删除定时任务
Mac下可以参考:
The first form of this command is used to install a new crontab from some named file or standard input if the
pseudo-filename `-' is given.
The following options are available:
-u Specify the name of the user whose crontab is to be tweaked. If this option is not given, crontab exam-
ines ``your'' crontab, i.e., the crontab of the person executing the command. Note that su(1) can con-
fuse crontab and that if you are running inside of su(1) you should always use the -u option for
safety's sake.
-l Display the current crontab on standard output.
-r Remove the current crontab.
-e Edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. The
specified editor must edit the file in place; any editor that unlinks the file and recreates it cannot
be used. After you exit from the editor, the modified crontab will be installed automatically.
FILES
/usr/lib/cron/cron.allow
/usr/lib/cron/cron.deny
DIAGNOSTICS
A fairly informative usage message appears if you run it with a bad command line.
SEE ALSO
crontab(5), compat(5), cron(8), launchctl(1)
STANDARDS
The crontab command conforms to IEEE Std 1003.2 (``POSIX.2''). The new command syntax differs from previous
versions of Vixie Cron, as well as from the classic SVR3 syntax.
AUTHORS
Paul Vixie <paul@vix.com>
BSD December 29, 1993 BSD
来源:CSDN
作者:LU_ZHAO
链接:https://blog.csdn.net/LU_ZHAO/article/details/104282662