
通过使用这个简单而强大的 Linux 命令行工具,来安排备份、文件清理以及其他任务。

在本期的《Linux 黑话解释》系列文章中,你将了解到 Linux 中的定时任务(cron job)功能。

在 Linux 系统中有一些其他开源项目可以结合或者替代 cron 系统使用。

cron 定时器是一个可以按照计划自动运行命令的工具。 定时器是一个可以按照计划自动运行命令的工具。

systemd 提供定时器有一段时间了,定时器替代了 cron 功能,这一特性值得看看。

cron 是一个调度守护进程,它以指定的时间间隔执行任务,这些任务称为 corn 作业,主要用于自动执行系统维护或管理任务。

定时器提供了比 cron 作业更为细粒度的事件控制。

与其手动执行重复性的任务,不如让 Linux 为你做。

at 命令可以很容易地安排 Linux 任务在你选择的任何时间或日期运行,让我们来看看它能为你做什么。

cron 任务用于“自动执行的任务”,它有助于简化重复的、有时是乏味的任务的执行。

如果你在处理 Cron 定时任务的时候为了以防万一,可以尝试使用 Crontab UI,它是一个可以在类 Unix 操作系统上安全轻松管理 Cron 定时任务的 Web 页面工具。

Cron 通常用于运行计划备份、监视磁盘空间、定期删除不再需要的文件(例如日志文件)、运行系统维护任务等等。在本简要指南中,我们将看到 Linux 中 Cron 任务的基本用法。

我知道如何使用 yum 命令行 更新系统,但是我想用 cron 任务自动更新软件包。

系统管理员(在许多好处中)的挑战之一是在你该睡觉的时候去运行一些任务。例如,一些任务(包括定期循环运行的任务)需要在没有人使用计算机资源的时候去运行,如午夜或周末。在下班后,我没有时间去运行命令或脚本。而且,我也不想在晚上去启动备份或重大更新。

cron 和 anacron 主要的区别在于 cron 能在那些持续运行的机器上有效地运行,而 anacron 是针对那些会在一天内或者一周内会关机的机器。

定时任务(cron job)被用于安排那些需要被周期性执行的命令。利用它,你可以配置某些命令或者脚本,让它们在某个设定的时间内周期性地运行。

提问: 我想在我的Linux中安排一个计划任务,该任务在固定时间周期性地运行。我该如何在Linux中添加一个cron任务? cron是Linux中默认的计划任务。使用cron,你可以安排一个计划(比如:命令或者shell脚本)周期性地运行或者在指定的分钟、小时、天、周、月等特定时间运行。cron在你安排不同的常规维护任务时是很有用的,比如周期性地备份、日志循环、检查文件系统、监测磁盘空间等等。 (题图来自 eagleapex.com) 从命令行中添加cron任务 要添加cron任务,你可以使用称为crontab的命令行工具。 输入下面的命令会创建一个以当前用户运

我最近在写一些执行备份工作的脚本,我决定使用systemd timers而不是对我而已更熟悉的cron jobs来管理它们。 在我使用时,出现了很多问题需要我去各个地方找资料,这个过程非常麻烦。因此,我想要把我目前所做的记录下来,方便自己的记忆,也方便读者不必像我这样,满世界的找资料了。 在我下面提到的步骤中有其他的选择,但是这里是最简单的方法。在此之前,请查看systemd.service, systemd.timer,和systemd.target的帮助页面(man),学习你能用它们做些什么。 运行一个简单的脚本 假设你有一个脚本叫:/usr/local/bin/myscript ,你想要