crontab

Crontab Day of the Week syntax

戏子无情 提交于 2019-12-02 14:05:20
In crontab does the Day of the Week field run from 0 - 6 or 1 -7 ? I am seeing conflicting information on this. wikipedia states 0-6 and other sites I have seen are 1-7 . Also what would be the implication or either using 0 or 7 incorrectly? i.e. would the cron still run? 0 and 7 both stand for Sunday, you can use the one you want, so writing 0-6 or 1-7 has the same result. Also, as suggested by @Henrik, it is possible to replace numbers by shortened name of days, such as MON , THU , etc: 0 - Sun Sunday 1 - Mon Monday 2 - Tue Tuesday 3 - Wed Wednesday 4 - Thu Thursday 5 - Fri Friday 6 - Sat

gentoo crontab: why this simple crontab is not working?

点点圈 提交于 2019-12-02 13:21:15
I use a GENTOO distribution. crontab -e 35 12 * * * root php5 /home/www/cron.php When I run manually: php5 php5 /home/www/cron.php This works (it sends me an email) Then I check date at 12:35pm... nbothing ! I also tried with: */1 * * * * root php5 /home/www/cron.php So it sends me an email every minute and NOTHING ! I also tried with full path of php5 */1 * * * * root /usr/local/bin/php5 /home/www/cron.php Looks like crontab does not work: any idea why ? What do I do wrong ? regards The syntax you use in crontab -e does not allow you to specify the user name; it always runs as yourself. So,

14-2 任务计划

故事扮演 提交于 2019-12-02 11:42:55
任务计划 Linux任务计划、周期性任务执行 未来的某时间点执行一次任务 at 指定时间点,执行一次性任务 batch 系统自行选择空闲时间去执行此处指定的任务 周期性运行某任务 cron at任务 包:at at 命令:at [option] TIME 常用选项: V 显示版本信息 t time 时间格式 [[CC]YY]MMDDhhmm[.ss] l 列出指定队列中等待运行的作业;相当于atq d 删除指定的作业;相当于atrm c 查看具体作业任务 f /path/file 指定的文件中读取任务 m 当任务被完成之后,将给用户发送邮件,即使没有标准输出 注意:作业执行命令的结果中的标准输出和错误以邮件通知给相关用户 TIME:定义出什么时候进行 at 这项任务的时间 HH:MM [YYYY-mm-dd] noon, midnight, teatime(4pm) tomorrow now+#{minutes,hours,days, OR weeks} at时间格式: HH:MM 02:00 在今日的 HH:MM 进行,若该时刻已过,则明天此时执行任务 HH:MM YYYY-MM-DD 02:00 2016-09-20 规定在某年某月的某一天的特殊时刻进行该项任务 HH:MM[am|pm] [Month] [Date] 04pm March 17 17:20 tomorrow

Linux crontab命令详解

拥有回忆 提交于 2019-12-02 10:56:45
crontab:定时任务的守护进程,精确到分,设计秒的我们一般写脚本 -->相当于闹钟 日志文件: ll /var/log/cron* 编辑文件: vim /etc/crontab 进程:ps -ef | grep crond ==> /etc/init.d/crond restart 作用:定时备份,实时备份 常见命令参数 1 2 3 4 5 6 7 8 usage: crontab [-u user] file crontab [-u user] [ -e | -l | -r ] (default operation is replace, per 1003.2) -e (edit user's crontab ) -l (list user's crontab ) -r (delete user's crontab ) -i (prompt before deleting user's crontab ) -s (selinux context) 定时任务分类 Linux下的任务调度分为两类,系统任务调度和用户任务调度。 系统任务调度:系统周期性所要执行的工作,比如写缓存数据到硬盘、日志清理等。 在/etc/crontab文件,这个就是系统任务调度的配置文件。 用户任务调度:用户定期要执行的工作,比如用户数据备份、定时邮件提醒等。 用户可以使用 crontab

Crontab and testing a command to be executed

你说的曾经没有我的故事 提交于 2019-12-02 08:48:25
I'm quite new to cron and crontab. I've edited the crontab file and I need to execute manually one of commands so I can try it and test it beforehand. How do I do that? If it fails, is there a mode that shows the errors? Write a shell script that you can test. Execute that shell script from the crontab. Remember that cron provides barely any environment - so your script may have to fix that. In particular, your profile will not be used. Do not get fancy with what you put in the crontab. Build a debug mode into your shell script. No, there isn't specifically a mode that shows errors. Usually,

计划任务crontab

风格不统一 提交于 2019-12-02 08:08:28
第一次编辑计划任务, 会提示选择文本模式, 选择3 (vim.basic)即可. 语法: * * * * * command 有几个注意的点: * */6 * * * command 表示每天的6:00, 12:00 18:00 24:00 里的每一分钟执行一次, 开始我以为是按照我编辑计划任务的时间算起, 实际不是, 实际是固定的, 系统已经计算好了. #未完待续... crontab -u bneglect -l 查看benglect用户的计划任务, crontab -e 默认编辑当前用户的, crontab -u otheruser -e 编辑otheruser用户的计划任务. 计划任务脚本所在目录: /var/spool/cron/crontabs/ 计划任务不执行的原因: cron服务是否启动(Ubuntu上是cron, 有的系统是crond) service cron status 或 systemctl status cron 查看服务状态 service cron start 或 systemctl start cron 启动 shell脚本是否有语法错误, 可以手动执行shell脚本, 如果成功执行, 就是别的原因 shell脚本的路径要写成 绝对路径 ,不能使用相对路径 创建计划任务的用户没有执行shell脚本的权限, 举例: bneglect创建的计划任务,

Linux命令之crontab定时任务

大憨熊 提交于 2019-12-02 07:45:19
Linux crontab命令 Linux 命令大全 Linux crontab是用来定期执行程序的命令。 当安装完成操作系统之后,默认便会启动此任务调度命令。 crond命令每分锺会定期检查是否有要执行的工作,如果有要执行的工作便会自动执行该工作。 而linux任务调度的工作主要分为以下两类: 1、系统执行的工作:系统周期性所要执行的工作,如备份系统数据、清理缓存 2、个人执行的工作:某个用户定期要做的工作,例如每隔10分钟检查邮件服务器是否有新信,这些工作可由每个用户自行设置 语法 crontab [ -u user ] file 或 crontab [ -u user ] { -l | -r | -e } 说明: crontab 是用来让使用者在固定时间或固定间隔执行程序之用,换句话说,也就是类似使用者的时程表。 -u user 是指设定指定 user 的时程表,这个前提是你必须要有其权限(比如说是 root)才能够指定他人的时程表。如果不使用 -u user 的话,就是表示设定自己的时程表。 参数说明 : -e : 执行文字编辑器来设定时程表,内定的文字编辑器是 VI,如果你想用别的文字编辑器,则请先设定 VISUAL 环境变数来指定使用那个文字编辑器(比如说 setenv VISUAL joe) -r : 删除目前的时程表 -l : 列出目前的时程表 时程表的格式如下:

linux crontab 定时任务

泄露秘密 提交于 2019-12-02 07:36:14
crontab 定义时任务并不难,只是死记更背有点难受。国外人的思维方式有时候就是违反思维逻辑。比如:中国人写收货地址是从大到小,一步一步清晰明了;外国人就不一样了,先从小地方开始,你根本不知道是啥子地方,只有看完之后反推一遍,你才明白。唉,打个不贴切地比喻,整得像个递归算法似的。 #查看是否安装了该服务 rpm -qa|grep cron #查看cron的状态 systemctl status crond #设为开机启动 systemctl enable crond #启动crond服务 systemctl start crond #查看定时任务列表 crontab -u username -l #编辑 crontab 的配置文件,默认 crontab 会每分钟检查一次任务配置文件 crontab -u username -e -------------------------------------------------------------------------------------------- # crontab 基本格式:分(0 - 59) 时(0 - 23) 日(1 - 31) 月(1 - 12) 周(0 - 6,0:日) 命令 # */30 * * * * /usr/local/command # 从后往前数,周月--日时分,当跳过所有 " * ",

unexpected EOF cronjob error

眉间皱痕 提交于 2019-12-02 05:39:26
问题 I have the following cronjob: 2 15 * * * mysqldump -u user -ppass dbname | gzip -9 -c > /var/www/backup/dump-$(date +%Y-%m-%d).sql.gz but it produces following error: /bin/sh: -c: line 0: unexpected EOF while looking for matching ')' /bin/sh: -c: line 1: syntax error: unexpected end of file I tried ommiting -c but no luck. I have one more line in my crontab but I don't think it's related: 0 0 * * * find /var/www/backup/* -mtime +15 -exec rm {} \; Thanks 回答1: The % character should be escaped

The script runs from command line but crontab fails

假如想象 提交于 2019-12-02 05:35:25
I'm still learning Bash and I'm having a problem with my script. I want to filter some calls with this script that is analyzing a call log, every 2 minutes as cronjob. The problem is that I can run it manually but it fails when run automatically from cron. I don't know why. It shouts something about permissions, so I kinda patched the script, so if it seems dirty I'm sorry. #!/bin/bash YESTERDAY=$((`date +'%s'`-86400)) AYER=`date -d "1970-01-01 $YESTERDAY sec" +"%Y%m%d"` FECHA=`date +"%Y%m%d"` FILENAME="$FECHA.log" FILE_LINE="$FECHA.last" FILE="/apps/sittel/rawdata/mitel.$FECHA" # Limpiar