您的位置:首页 > 运维架构 > Linux

Linux 服务器设置定时任务(整理)

2016-09-19 16:10 639 查看
写一个shell.

#!/bin/bash

direc="/opt/tmp/aaa/a"

for dir2del in $direc/* ; do
if [ -f "$dir2del" ]; then
rm -rf $dir2del
fi
done


2.给这个文件加权限:

chmod +x filename.sh


crontab 执行任务调度

crontab -e


4.每五分钟执行

*/5 * * * *   /bin/sh  /home//del.sh


5.重启。

service crond restart


参考资料:

(http://www.cnblogs.com/cute/archive/2012/05/11/2496213.html)

http://zhangzhaoaaa.iteye.com/blog/1991245
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux