Linux定时任务执行脚本

时间:2022-02-21 07:48:09
# 查看cornd状态
[root@iZwz93e3cxesxun8e2ti7rZ home]# /sbin/service crond status
Redirecting to /bin/systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-07-04 18:17:19 CST; 9min ago
Main PID: 24661 (crond)
CGroup: /system.slice/crond.service
└─24661 /usr/sbin/crond -n

#建立crontab文件

[root@iZwz93e3cxesxun8e2ti7rZ app]# cat crontab
*/1 * * * * /app/test.sh >> "/home/test.log"
#建立shell脚本
[root@iZwz93e3cxesxun8e2ti7rZ app]# cat test.sh#! /bin/shecho "11111111111111111111111111111"

# shell脚本给与执行权限

[root@iZwz93e3cxesxun8e2ti7rZ app]# chmod 777 test.sh


# crontab crontab


#service crond start

# cat /home/test.log