crontab

linux定时任务

风格不统一 提交于 2019-12-12 19:36:00
crontab 命令 查看当前的定时任务 crontab -l 编辑定时任务 crontab -e 格式: * * * * * shell 第一个*:分钟(0~59) 第二个*:小时(0~23) 第三个*:日(0~31/30/28/29) 第四个*:月(1~12) 第五个*:星期(1~7) shell:需要执行的命令 例如: 每分钟打印一次系统日期 编辑定时任务 crontab -e 内容 * * * * * date 或者: 定时执行脚本 编辑脚本 vim name_1.sh 编辑定时任务 crontab -e 内容 * * * * * /全路径/name_1.sh 查看效果 来源: https://www.cnblogs.com/mhsxq/p/12029060.html

Log4j2 Logging is not working when application is running through crontab in linux

好久不见. 提交于 2019-12-12 18:37:51
问题 I have a java application in which I implemented logging. Here are the files log4j2.xml <configuration xmlns:xi="http://www.w3.org/2001/XInclude" status="WARN"> <xi:include href="log4j-xinclude-appenders.xml" /> <xi:include href="log4j-xinclude-loggers.xml" /> </configuration> log4j-xinclude-appenders.xml <appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </Console> <Routing name="RoutingAppender"> <Routes

run php script every 5 seconds

ⅰ亾dé卋堺 提交于 2019-12-12 18:26:35
问题 I know that for running php script every time (seconds or minute) we can use Cron (job or tab) but cron has a 60 sec granularity so we are forced to have an infinite loop for running php script . For example we can write the code below to call it at the top of the script: #!/bin/bash while [ true ]; do #put php script here done but it's illogical because we must change php execution time in php.ini so we have a lot of problems (Security , overflow , ... ) in server . well, what should we do

Date time format in UNIX crontab

大城市里の小女人 提交于 2019-12-12 16:06:01
问题 I'm running a cron every 6 hours to backup my database. I want the filename to contain the date & time it was created in the following format: mysqlbackup_22/5/2013_15:45.sql.gz This is the command I run: date=`date -d`; mysqldump -uusername -ppassword dbname | gzip > /path/to/dir/mysqlbackup_$date.sql.gz What do I need to change date -d to? 回答1: If you use a date format like date +"%d-%m-%Y_%H:%M" in your crontab you may need to escape the % characters with a backslash, like this: date +"\%d

How to delegate within a crontab to use another file as a crontab? aka Crontab in SVN/CVS?

别来无恙 提交于 2019-12-12 09:52:48
问题 Maybe theres another solution to this. I built a web app that requires 5-10 crons to keep it maintained and various intervals. I want to check-in the crontab into version control, so that it can be easily deployed to other servers. I would like to be able to put a line in the /etc/crontab file that would tell it to look into /myapp/app.crontab file and treat all the lines in that file as crontab entries... ie: 0 1 * * * root /bin/sh /do/something.sh Why not just checkin /etc/crontab? Because

Crontab executes only first line

拈花ヽ惹草 提交于 2019-12-12 09:42:01
问题 I'm trying to setup several cron jobs on VPS under centos/whm. I've added to /var/spool/cron/root following lines: */5 * * * * find /some-dir/* \( ! -iname ".ht*" \) -delete */10 * * * * find /some-other-dir/* \( ! -iname ".ht*" \) -delete but only the first line executed ( for /some-dir/). If I swap lines - /some-other-dir/ executed, /some-dir/ - not. I've tried to put semicolons at the end of each line, to put spaces, tabs, change file encoding - nothing. How can I make cron process both

Execute Python (selenium) script in crontab

不问归期 提交于 2019-12-12 09:38:12
问题 I have read most of the python/cron here in stackoverflow and yet couldn't make my script run. I understood that I need to run my script through shell (using zsh & ipython by the way), but really I have no idea what to do :/ My simple code: In the crontab- */1 * * * * ipython /home/usr/Data/progs/cron_test.py My python script- import pickle from selenium import webdriver driver = webdriver.Firefox() driver.get('http://www.google.com') t=driver.current_url pickle.dump(t,open('noreal','wb')) I

Cronjobs in Docker container how get them running?

佐手、 提交于 2019-12-12 09:19:05
问题 I've got some cronjobs in my debian docker container. They don't start automatically why? Do I have to do some workarounds? 回答1: If you are running containers in docker, you can add cron tasks on the docker host machine to execute commands in the docker containers. For example, to run 'stress' application in your container every 5 minutes you can add the following (substituting your container ID of course) to your crontab: */5 * * * * docker exec c78ddbed4ad9 /bin/sh -c 'stress -d 1 --hdd

How to setup cron job on Amazon Linux AMI

五迷三道 提交于 2019-12-12 08:37:42
问题 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

How do I write a Perl script to use curl to process a URL?

折月煮酒 提交于 2019-12-12 08:26:38
问题 I have a very simple task. I have a crontab that will run a script every hour. The script is meant to simply process a URL. This is what I have. It doesn't work. I get a syntax error. #!/usr/bin/perl curl http://domain.com/page.html; I haven't worked in Perl in years and wasn't very adept when I did. SOLUTION Thanks, Alex for pointing me to the correct path! crontab */30 * * * * curl http://domain.com/path.html 回答1: You can either use curl via backticks my $curl=`curl http://whatever` or you