crontab

八周一次课(5月11日)linux任务计划cron、chkconfig工具、systemd管理服务、unit介绍、target介绍

混江龙づ霸主 提交于 2019-12-04 07:37:11
10.23 linux任务计划cron 配置文件, cat /etc/crontab 重点是上图第二个红色框框的内容,前面的五个“ ”,分别表示分钟、小时、日期、月份、星期。user-name 表示用户名,没有的话默认是 root ,command to be executed 表示要执行的命令。 输入命令 crontab -e,回车,就会进入到配置文件里 用法和 vim 是一样的,按字母“i”进入编辑模式,“Esc”退出编辑,“:wq”保存并退出, “:q”退出,“:q!”强制退出。 现在来讲解一下任务计划: “0 3 ”:表示每天的凌晨3点。表示所有的范围。分钟位就是0-59,小时位表示0-23,日期表示1-31,月份表示1-12,星期表示1-7。 “0 3 1-10 /2 2,5 ”:表示双月1-10号的周二和周五凌晨3点。其中,月份这边“/2”表示可以被2除,就是双月的意思,小时这边/2就表示每隔两小时。 这边没有年份,是因为星期可以确定唯一性,每一年的月份和星期都不一样。 0 3 1-10 /2 2,5 /bin/bash /usr/local/sbin/123.sh >>/tmp/123.log 2>>/tmp/123.log 这个任务计划里,/bin/bash 表示用户,/usr/local/sbin/123.sh 表示文件里面有个shell脚本,执行里面的命令。>>

gentoo crontab: why this simple crontab is not working?

◇◆丶佛笑我妖孽 提交于 2019-12-04 07:04:45
问题 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 回答1: The

Updating CRON with bash script

。_饼干妹妹 提交于 2019-12-04 06:03:13
Can anyone see my syntax error here? Trying to edit/update a cron job, but the file is not being updated. crontab -l | sed 's%*/5 * * * * cd /home/administrator/anm-1.5.0 && ./anm.sh%*/10 * * * * cd /home/administrator/anm-1.5.0 && ./anm.sh%' | crontab - * UPDATE * So im still having trouble with this. Ultimately I am trying to pull a value from a config file $FREQ (minutes) to run the job. The script will first check to see if the value in the config is different than the value currently in the crontab. If the value is different, it will update the crontab with the new value. The crontab

setup cron from morning to evening only [closed]

筅森魡賤 提交于 2019-12-04 05:48:07
I have to run daily cron. Cron must running time will be morning 11 AM to evening 7 PM. In this given time cron must run at every 15 mins daily. same thing after in night cron must run at every hour? Is this possible with linux cron scheduling type. Or i have to manage this from any scripting language. */15 11-18 * * * statement/to/run 0 0-10,19-23 * * * statement/to/run Should do what you need. */15 or 0,15,30,45 will both do the same thing and run every 15 minutes. You'll need to break it into two entries since you want it to run differently during different times of day. I don't think you

What does -f stand for in “php -f” when running a cron job?

牧云@^-^@ 提交于 2019-12-04 04:53:49
问题 What does the "-f" in say * * * * * php -f myscript.php stand for? 回答1: According to the PHP Command-Line options reference: http://php.net/manual/en/features.commandline.options.php the -f option indicates which file the PHP engine should execute, in this case myscript.php . 来源: https://stackoverflow.com/questions/12486686/what-does-f-stand-for-in-php-f-when-running-a-cron-job

How to run a php url with parameters in cron tab [duplicate]

拥有回忆 提交于 2019-12-04 04:29:44
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to run a php script in cron I have a php script that is set to run in cron.I want to run the url with passing one parameter. I tried to pass parameters as query string and put in crontab it didn't work. How to run a url with parameters using cron? php /var/www/prod/Reports/report.php?email=sample@sample.com 回答1: Ideally running PHP in command line interface (CLI) you would use $argv and $argc globals to pass

How to setup cron job on Amazon Linux AMI

a 夏天 提交于 2019-12-04 03:40:30
I am hosting Tiny Tiny RSS site hosted on Amazon Linux AMI To update the feed automatically I have to run following cron job. Reference http://tt-rss.org/redmine/projects/tt-rss/wiki/UpdatingFeeds */30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet Here is the step I did: sudo su cd /etc crontab -e add this line */30 * * * * /usr/bin/php /var/www/html/tt-rss/update.php --feeds --quiet But I still got the message "Update Daemon is not running". May I know is this correct step for cron job? My first setup. Thanks, Alex You should first inspect the cron log file /var/log

why #!/usr/bin/env ruby doesn't work in crontab?

六眼飞鱼酱① 提交于 2019-12-04 00:54:22
问题 I have install ruby by rvm (system-wide), and worked correctly via normal console and my rails program is behaving correctly with both rails runner and apache2+passenger . Now in a crontab, I called rails runner foo.bar , it gives up, carefully examine the log i see that: /usr/bin/env: ruby: No such file or directory Anyone knows why /usr/bin/env doesnt work in crontab? 回答1: If you installed ruby via rvm, ruby probably isn't in /usr/bin. Depending on where rvm is installed: bash -c "source

alternative to cron? [closed]

穿精又带淫゛_ 提交于 2019-12-04 00:43:47
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 6 years ago . Does anyone know of a good alternative to cron? I would like something that can be run with different time zones. You may consider Quartz (a java-based solution), that can take advantage of Date build in the appropriate TimeZone . For the future readers, consider Chronos, developed and open sourced by AirBnB. check it out at http://nerds.airbnb.com/introducing

/bin/sh: 1: Syntax error: EOF in backquote substitution

拈花ヽ惹草 提交于 2019-12-04 00:28:49
问题 I created a new task in crontab as shown below : */2 * * * * mongodump --db prodys --out /backup/databases/mongoDatabases/`date +"%m-%d-%y"` I'm getting following error : /bin/sh: 1: Syntax error: EOF in backquote substitution Please help, I don't have any clue whats wrong. 回答1: The problem is that cron treats % as newlines. From crontab POSIX man page: Percent-signs (%) in the command, unless escaped with backslash \, will be changed into newline characters, and all data after the first %