linux 中通过shell在crontab定时任务添加任务

crontab是linux下自带的,最小单位为分钟,如实现一分钟调用一下machinestatusinfo.sh脚本


shell名随便起,放到一个目录下,通过chmod +x ./名 命令添加执行权限

#!/bin/bash


crontab -l > crontab.bak
echo "* * * * * /usr/local/bin/sys/machinestatusinfo.sh" >> crontab.bak
crontab crontab.bak

./etc/init.d/cron restart

启动该shell即可,可以通过crontab -e查看添加的定时任务

猜你喜欢

转载自blog.csdn.net/qq_29175301/article/details/78413759