使用service替代crontab执行小于1分钟间隔的定时任务

服务需要为了实现验证短信的异步发送,需要每隔10秒执行发送任务,但是cron显然实现不了。因此需要一个替代品——service

新增一个linux service,包含两个文件:

文件1:/etc/systemd/system/whmcs-sms.service



[Unit]

Description=Send WHMCS SMS

[Service]

User=www

ExecStart=/usr/bin/php -q /www/wwwroot/cloudraft-whmcs/modules/addons/sms_center/cron.php

文件2:/etc/systemd/system/whmcs-sms.timer



[Unit]

Description=Send WHMCS SMS every 10 seconds

[Timer]

OnBootSec=10

OnUnitActiveSec=10

AccuracySec=1ms

[Install]

WantedBy=timers.target


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/497.html
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy