crontab

Why is crontab not executing my PHP script?

醉酒当歌 提交于 2019-11-26 17:45:50
I have built one php file to check some result, so that I need to setup a cronjob. I set one to run every 30 minute, so that the results will be send. However, I don't know why my crontab did not run after every 30 minute. Here is how I set the crontab: */30 * * * * php /var/www/html/result.php I have confirmed my file directory is correct. What I not sure is about the timing part: isn't it possible to use */30 * * * * or 30 * * * * ? I set */30 * * * * and did not work. fedorqui Given */30 * * * * php /var/www/html/result.php There are multiple possibilities why it is not working: First of

Why percent signs (%) do not work in crontab? [duplicate]

瘦欲@ 提交于 2019-11-26 17:20:11
问题 This question already has an answer here : How is % special in crontab? (1 answer) Closed 10 months ago . I'm writing files out to a log ran by a bash script using cron. The call on cron looks like this: */25 * * * * bash script.sh > "/var/log/$(date +%Y-%m-%d_%H:%M).log" But when I check the crontab it records as */25 * * * * bash script.sh > "/var/log/$(date +).log" And it never writes the log file. Is there something I need to change to get cron to write the date? 回答1: It is a matter of

crontab

你。 提交于 2019-11-26 17:08:41
使用crontab你可以在指定的时间执行一个shell脚本或者一系列Linux命令。例如系统管理员安排一个备份任务使其每天都运行 如何往 cron 中添加一个作业? # crontab –e 0 5 * * * /root/bin/backup.sh 这将会在每天早上5点运行 /root/bin/backup.sh Cron 各项的描述 以下是 crontab 文件的格式: {minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script} o minute: 区间为 0 – 59 o hour: 区间为0 – 23 o day-of-month: 区间为0 – 31 o month: 区间为1 – 12. 1 是1月. 12是12月. o Day-of-week: 区间为0 – 7. 周日可以是0或7. Crontab 示例 1. 在 12:01 a.m 运行,即每天凌晨过一分钟。这是一个恰当的进行备份的时间,因为此时系统负载不大。 1 0 * * * /root/bin/backup.sh 2. 每个工作日(Mon – Fri) 11:59 p.m 都进行备份作业。 59 11 * * 1,2,3,4,5 /root/bin/backup.sh 下面例子与上面的例子效果一样: 59

crontab命令使用

此生再无相见时 提交于 2019-11-26 16:14:50
cron:周期性计划任务、循环性计划任务,主要用于备份数据。 crontab usage:crontab [-u user] [ -e | -l | -r ] -u <user> define user #指定用户 -e edit user's crontab #编辑计划任务 -l list user's crontab #查看计划任务 -r delete user's crontab #删除计划任务 1、crontab -e 编辑周期性计划任务的内容 2、查看配置:cat /etc/crontab 时间 min hour day month week command 分钟 小时 日 月 周 动作(任务命令) 0-59 0-23 1-31 1-12 0-7 命令或脚本(写绝对路径) 30 2 1 * * rm -rf /tmp/* //每月1号的2:30分删除/tmp目录下的所有文件 5 * * 6 3 rm -rf /tmp/* //每年6月的每周三每小时的5分钟删除/tmp目录下的所有文件 6 6 * 6 6 rm -rf /tmp/* //每年6月的周六的6点6分钟删除/tmp目录下的所有文件 * 任何时刻 - 一段时间 // 8-11 * * * * rm -rf /tmp/* //每小时的8分钟 9分钟 10分钟 11分钟 删除/tmp目录下所有文件 , 分隔

 进程和计划任务任务管理

孤人 提交于 2019-11-26 15:52:27
进程和计划任务任务管理 1、程序和进程的关系 (1)程序 保存在硬盘、光盘等介质中的可执行代码和数据 静态保存的代码 (2)进程 在 CPU 及内存中运行的程序代码 动态执行的代码 父、子进程:每一个进程可以创建一个或多个进程 2、静态查看进程信息 [root@localhost ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.3 56640 6672 ? Ss 00:22 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 24 root 2 0.0 0.0 0 0 ? S 00:22 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 00:22 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 00:22 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S 00:22 0:00 [migration/0]. (1) USER:启动该进程的用户账号的名称。 PID:该进程在系统中的PID号,在当前系统中是唯一的。 %CPU: CPU占用的百分比。 %MEM:内存占用的百分比。 VSZ

liunx定时执行php脚本

老子叫甜甜 提交于 2019-11-26 15:45:03
很多时候我们有希望服务器定时去运行一个脚本来触发一个操作,比如使用七牛的工具上传,如果同步文件里面有新增加一个文件,这个时候我们可以提供定时脚本去完成我们需要的同步命令(七牛的qrsbox工具是自动会同步的,只需要在同步文件夹里面增加一个文件就会自动监听上传)。 1.安装crontab [root @CentOS ~]# yum install vixie-cron [root @CentOS ~]# yum install crontabs vixie-cron软件包是cron的主程序; crontabs软件包是用来安装、卸装、或列举用来驱动 cron 守护进程的表格的程序。 2.开启crontab服务 service crond start //启动服务 用以下的方法启动、关闭这个cron服务: service crond start //启动服务 service crond stop //关闭服务 service crond restart //重启服务 service crond reload //重新载入配置 查看crontab服务状态:service crond status 手动启动crontab服务:service crond start 查看crontab服务是否已设置为开机启动,执行命令:ntsysv 加入开机自动启动: chkconfig –level 35

linux中Cron定时任务系统命令详解

泪湿孤枕 提交于 2019-11-26 15:01:19
linux中Cron定时任务系统命令详解 分类: Linux VPS教程 作者:阿川 发布时间:October 13, 2011 有很多同学在购买 VPS 之后,需要用到计划任务.但是又对计划任务不太了解,所以.今天我们的帮助中心主要是给大家提供一些关于计划任务的 Linux教程 . cron是一个linux下 的定时执行工具 ,可以在无需人工干预的情况下运行作业。由于Cron 是Linux 的内置 服务,但它不自动起来,可以用以下的方法 启动、关闭 这个服务: 1. /sbin/service crond start //启动服务 1. /sbin/service crond stop //关闭服务 1. /sbin/service crond restart //重启服务 1. /sbin/service crond reload //重新载入配置 你也可以将这个服务在系统启动的时候自动启动: 在/etc /rc.d/rc.local 这个脚本的末尾加上: 1. /sbin/service crond start 现在C ron这个服务已经在进程里面了,我们就可以用这个服务了,Cron服务提供以下几种接口供大家使用: 1.直接用crontab 命令编辑 cron服务提供crontab命令来设定cron服务的,以下是这个命令的一些参数 与说明: 1. crontab -u /

How to specify in crontab by what user to run script?

拟墨画扇 提交于 2019-11-26 14:06:36
I have few crontab jobs that run under root, but that gives me some problems. For example all folders created in process of that cron job are under user root and group root. How can i make it to run under user www-data and group www-data so when i run scripts from my website i can manipulate those folders and files? My server runs on Ubuntu. Current crontab job is: */1 * * * * php5 /var/www/web/includes/crontab/queue_process.php >> /var/www/web/includes/crontab/queue.log 2>&1 Instead of creating a crontab to run as the root user, create a crontab for the user that you want to run the script.

手把手教你crontab排障

点点圈 提交于 2019-11-26 12:33:15
crontab 配置文件 SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # .—————- minute (0 – 59) # | .————- hour (0 – 23) # | | .———- day of month (1 – 31) # | | | .——- month (1 – 12) OR jan,feb,mar,apr … # | | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR #sun,mon,tue,wed,thu,fri,sat # | | | | | # m h dom mon dow command # * * * * * command will be executed 例如: */5 * * * * root /usr/libexec/atrun minute(m) : 代表一小时内的第几分,范围 0-59。 hour (h) : 代表一天中的第几小时,范围 0-23。 mday (dom) : 代表一个月中的第几天,范围 1-31。 month(mon) : 代表一年中第几个月,范围 1-12。 wday (dow) : 代表星期几,范围 0-7 (0及7都是星期天)。 who : 要使用什么身份执行该指令

crontab 定时任务没有响应 检测步骤

情到浓时终转凉″ 提交于 2019-11-26 12:08:01
设置规则 参考 : https://blog.csdn.net/weixin_41004350/article/details/78492367 定时任务启动python脚本规则案例 参考: https://www.jianshu.com/p/cf1dbd17ee2f # 防止出现一些路径错误,使用绝对路径 */1 * * * * /home/anaconda3/bin/python3 home/mysticbiant/code/test.py >>/home/mysticbiant/test.py.log 2>&1 & 检查crontab是否启动 systemctl status crond 如果没有启动,自己搜索一下如何启动crontab. 检查crontab日志 # 需要切换root才能看到日志 tail -f /var/log/cron 如果日志没有在对应的时间启动,就是有问题。 检查账号权限和路径 这个属于重点,很多新手在这个问题都会搞错,请仔细阅读 crontab的定时任务计划规则是一个账号独立一份,各自互不影响原则。比如说root有自己独立的定时任务计划,你创建的mysticbinary子账号也有自己独立的定时任务计划,所以你书写的重定向规则 >>out.log ,会在你对应的账号路径下生成。比如你使用root创建了crontab定时任务,那么就得切换到/root