crontab

linux crontab任务

大城市里の小女人 提交于 2019-12-04 00:11:16
使用crontab你可以在指定的时间执行一个shell脚本或者一系列Linux命令,例如系统管理员安排一个备份任务使其每天都运行。 crontab -e 编辑当前用户下的定时任务 */15 * * * * /home/ap/tunnel/command/dbjob/outbound/objob/ob_job_archive_all_10m.sh >> /home/ap/tunnel/command/dbjob/outbound/objob/outbound_runjob.log 2>&1 每15分钟执行ob_job_archive_all_10m.sh任务,并将结果输出到outbound_runjob.log日志中 0 3 * * * /home/ap/tunnel/command/dbjob/magw/job_magw.sh >> /home/ap/tunnel/command/dbjob/magw/magw_runjob.log 2>&1 每天凌晨三点执行job_magw.sh脚本,并把结果输出到/magw_runjob.log日志中 Cron 各项的描述 以下是 crontab 文件的格式: {minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script} o minute:

Linux 命令之 crontab

拈花ヽ惹草 提交于 2019-12-03 23:07:20
crontab 简介 crontab 主要用于需要管理周期执行定时任务的场景 crontab 安装 (有些系统默认已经带了 crontab,无需安装的朋友可以直接跳过本节) 安装: yum install -y vixie-cron yum install -y crontabs 启动: systemctl start crond.service 重启: systemctl restart crond.service 设置开机启动: systemctl enable crondservice 命令格式 crontab 主要有以下几种命令格式 crontab [-u user] file crontab [-u user] [-l | -r | -e] [-i] [-s] crontab -n [ hostname ] crontab -c 我们发现crontab 的命令还挺多的,我们先从最常用的开始: crontab -e 这个命令用于编辑定时任务列表,当我们输入完命令,按下回车键之后,它会使用默认编辑器(通常是vi/vim)打开一个文件,里面的内容可能是这样子的: 这很可能是你看到的,在设置任何定时任务之前,这里是看不到任何内容的,如果你已经设置了内容的话,那么看到的可能是这样的 这是我提前设置好的定时任务,我们暂时不解释这个配置的功能,但从这里可以知道,通过 crontab

Running a python script from crontab

狂风中的少年 提交于 2019-12-03 20:54:12
I've got a python program which runs via crontab and that works perfectly. However, I decided to add the ability to notify me of what it's doing, and suddenly it's failing. It runs from the command line, however, running it as a crontab program causes it to fail libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed. What am I doing wrong? Edit I would like this program to still run from cron and be able to take advantage of notifying the user of it's work. Is there any way to do this? Edit 2 I

Getting started with cronjobs on a Mac

对着背影说爱祢 提交于 2019-12-03 19:34:47
问题 I'm trying to get familiar with cron jobs, and I think I get the basic idea (scheduling, syntax, etc), But, I can't seem to get it right on my mac with Terminal - where exactly do I find the Crontab? How should I reference the paths to scripts? What I'm trying to do is hit a php script on a remote machine (http://...) - Is that possible at all? 回答1: To get started with launchd (instead of cron) you'll want to first create an empty .plist file, for example local.mytask.plist and put it

Insane crond behavior. keeps making defunct bash processes

余生颓废 提交于 2019-12-03 19:17:13
问题 I have a crontab that looks like: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ 0-59 * * * * /var/www/html/private/fivemin/zdaemon.php >> /dev/null & Simple as possible, right? zdaemon.php which I am just testing with is: #!/usr/bin/php <? while(true){ sleep(1); } ?> Whenever it runs it hangs like: root 15532 0.0 0.1 57228 1076 ? Ss 19:09 0:00 crond root 16681 0.0 0.1 72196 1428 ? S 21:46 0:00 crond root 16682 0.0 0.0 0 0 ? Zs 21:46 0:00 [bash] <defunct> root 16683 0.0

Daily Database backup using Cron Job

谁说我不能喝 提交于 2019-12-03 19:13:32
问题 Hi i want to take database backup at daily mid night using cron job... and the name of database backup should append with current date... the format of backup file should be mydata_yyyy_mm_dd.sql ... backup file should be placed in /root directory 回答1: something like 0 0 * * * /path/to/mysqldump ... > /path/to/backup/mydata_$( date +"%Y_%m_%d" ).sql should work. Please read man date man 5 crontab 回答2: Create a cron.sh file with this content: mysqldump -u root -p{PASSWORD} DBNAME 2>> "

Crontab not executing bash script

落花浮王杯 提交于 2019-12-03 16:41:23
I very very rarely use Linux and so don't have any experience with bash scripts and cron jobs. This is in fact my first attempt. So it's probably something really simple to fix. I have the following: /etc/cron.d/clear-mixtape-dir.sh permissions are: 644 #!/bin/bash # Clears the /tmp/mixtape2 directory rm -rf "/tmp/mixtape2/"* My crontab file looks like so: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ */15 * * * * /etc/cron.d/clear-mixtape-dir.sh >/dev/null 2>&1 I'm trying to execute the .sh script every 15 minutes. Everything i've found says this should work, but it

Testing Crontab on Debian Ubuntu

。_饼干妹妹 提交于 2019-12-03 15:47:09
I will preface this by saying I am very new to command line programming with Debian Ubuntu... I have been trying to set up a crontab list on a Debian Ubuntu server but have not been able to get it to work. Here is a sample: MAILTO=myemail@gmail.com * * * * * wall test * * * * * /usr/bin/python2.6 /home/user/test.py > /home/user/clean_tmp_dir.log The above shows up when I type "crontab -l" but no resulting output appears in the console. The "test.py" is supposed to generate a csv file but none is being created. I am not receiving any output/error emails. I tried to find a log, but "var/log/cron

Call function periodically in Java

江枫思渺然 提交于 2019-12-03 15:06:21
we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server and so on . what is crontab ? Is that work periodically ? Brian Agnew To call something periodically, see TimerTask If you need something more robust you can use Quartz As for crontab is the scheduling tool on Unix machines. For calling methods when server has high load, you have at least two possible approaches. Your App Server might have management hooks that would you allow to monitor its

Crontab every 5 minutes [closed]

左心房为你撑大大i 提交于 2019-12-03 14:56:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . How could i tell crontab to run every 5 minutes, but starting at the second minute of the hour. In other words, i would like to execute my script when minute % 5 = 2 . For example, my script should run at : 08:02 08:07 08:12 08:17 ... Thanks for your help! 回答1: There are two possibilities: 2,7,12,17... command *