使用 systemd 定时器代替 cron 作业

转载自:https://mp.weixin.qq.com/s/HpDVp1sNYve8b7OdoHdGNw

创建一个定时器

首先,创建一个运行基础东西的简单的服务,例如 free 命令。举个例子,你可能想定时监控空余内存。在 /etc/systemd/system 目录下创建如下的 myMonitor.server 单元文件。它不需要是可执行文件:

[Unit]
Description=Logs system statistics to the systemd journal
Wants=myMonitor.timer

[Service]
Type=oneshot
ExecStart=/usr/bin/free

[Install]
WantedBy=multi-user.target

未完待续---

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/15620593.html