liunx crontab 定时任务

注:一般情况下下,crontab任务是liunx  自带的

1、创建任务 -》crontab -e

2、创建任务之后,就会在/var/spool/cron 目录里面有一个root文件

文件内容格式可参考:*/1 * * * * /usr/bin/wget -q -O temp.txt http://***.com/demo.php

(每分钟执行一次)

3、在项目目录里面创建demo.php文件,

demo.php文件里面的内容为:

file_put_contents("test.txt", "hello world", FILE_APPEND);

可做参考,会在项目目录生成test.txt 文件并写入hello world 字符!

如果存在并有这些字符则证明此任务配置成功!

4、时间设置

每五分钟执行  */5 * * * *

每小时执行     0 * * * *

每天执行        0 0 * * *

每周执行       0 0 * * 0

每月执行        0 0 1 * *

每年执行       0 0 1 1 *

crontab常用命令:

/sbin/service crond start //启动服务
/sbin/service crond stop //关闭服务
/sbin/service crond restart //重启服务
/sbin/service crond reload //重新载入配置

//附liunx ftp链接不上,修改用户权限命令:(根目录不可写)

为了避免一个安全漏洞,从 vsftpd 2.3.5 开始,chroot 目录必须不可写。使用命令:

# chmod a-w /home/user

猜你喜欢

转载自my.oschina.net/u/3639899/blog/1530014