Articles of cron

MySQL重新启动时,通过crontab调度程序运行

我已经写了一个shell脚本,当它被杀死/终止时启动MySQL。 我使用crontab运行这个shell脚本。 我的cron在/root/mysql.sh下查找名为mysql.sh的脚本文件 sh /root/mysql.sh mysql.sh: cd /root/validate-mysql-status sh /root/validate-mysql-status/validate-mysql-status.sh validate-mysql-status.sh: # mysql root/admin username MUSER="xxxx" # mysql admin/root password MPASS="xxxxxx" # mysql server hostname MHOST="localhost" MSTART="/etc/init.d/mysql start" # path mysqladmin MADMIN="$(which mysqladmin)" # see if MySQL server is alive or not # 2&1 could be better but i would like to keep it simple […]

克朗不运行脚本

我有一个脚本,当调用时工作: /usr/local/bin/myscript #this works fine 该文件的权限是: -rwxr-xr-x 1 root root 155 Jan 27 09:34 myscript 我已经添加了一行到/ etc / crontab: * * * * * root /usr/local/bin/myscript 但是cron似乎不能运行这个。 crontab具有PATHvariables集: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 该脚本是/ var / tmp /目录的mysqldump: #!/bin/bash DAY=`date +%y%m%d` TIME=`date +%k%M` mysqldump test -u john -pxxxxxxx > /var/tmp/$DAY.$TIME.test.sql 我想不出有什么问题,但脚本没有运行。 编辑:/ var / log / syslog显示以下条目: Jan 27 […]

root cron作业无法从/ root /

我已经在root的crontab中定义了如下的cron作业: 0 1 * * * /usr/local/bin/tarsnap-backup-script > /tmp/tarsnapcron.txt 2> /tmp/tarsnapcron.err 该脚本是一个执行tarsnap的python脚本,它从/root/tarsnap.key读取密钥。 该密钥由root和chmod 400拥有。 如果我从bash shell运行脚本,它会执行没有错误。 但是,在cron下,我得到一个pythonexception打印到tarsnapcron.err : could not change directory to "/root": Permission denied 在bash中以root身份运行这个脚本和从root的crontab运行脚本有什么区别? 为什么后者不能从/root读取?

crontab找不到脚本

我有一个cron作业,每晚在我的用户下运行一次。 我使用crontab -e安装了它,并添加了一行: 0 1 * * * /home/username/diskreport.sh crontab的设置是为了给我发电子邮件的结果。 看起来随机我从Cron守护进程收到一封电子邮件,说明没有find脚本(与diskreport.sh的输出相反)。 /bin/sh: 1: /home/username/diskreport.sh: not found 我在脚本开始时遇到了一个错误,但是这并不妨碍脚本的运行。 它在sh和bash下运行良好: #~/bin/bash

克朗:指定一个小时在特定的一天开始/停止的可能性

在单个条目中,基于一周中的某一天指定运行小时/分钟的crontab语法是什么? 从星期一01:00到星期六01:00,每1分钟需要执行一次任务,所以在指定date(1-6)之后,我仍然必须从星期一排除00:00-00:59周日01:00-23:59。 我不想用三个条目而不是一个条目来完成它; 通过一些包装脚本做额外的时间检查也不是一个好的select。 Cron风味:vixie-cron,如果需要可以更改为另一个。

从HTML格式发送电子邮件,而不是文本

我试图发送email每1小时从cron作业正在执行一个php脚本,从数据库中提取数据,并以表格格式显示。 我有CentOs 6.1在哪里我创build了我的cron作业。首先我从terminalyum install cronie我键入crontab -e并打开VI编辑器 在那里我把我的cron与MAILTO一样 MAILTO="[email protected]" 10 * * * * php /var/www/html/myfile.php 它发送电子邮件每1小时过去10分钟,但其发送电子邮件中的文本内容,我不想要的。 myfile.php <?php $con=mysql_connect("localhost","root",""); mysql_select_db("dbname",$con); $to="[email protected]" $subject = 'Count User Login And Application'; //fetch between 06:00:00 to 08:30:00 09:00:00 to 10:00:00 $date=array('06:00:00','09:00:00'); $date1=array('08:30:00','10:00:00'); $msg = '<html><head>'; $msg .='<title>Some Title</title>'; $msg .='</head>'; $msg .='<h1>Test User</h1>'; $msg .='<table border="1" cellspacing="1">'; $msg .= […]

小时Clamscan cron脚本在阅读文件列表中失败

我有这段代码位于/etc/cron.hourly/hourlyclamscan。 #!/usr/bin/bash # Create Hourly Cron Job With Clamscan # Directories to scan SCAN_DIR=/home/transmission/Downloads # Temporary file LIST_FILE=`mktemp /tmp/clamscan.XXXXXX` # Location of log file LOG_FILE=/var/log/clamav/hourly_clamscan.log # Make list of new files /usr/bin/find "$SCAN_DIR" -type f -mmin -60 -fprint ${LIST_FILE} # Scan files and remove infected /usr/bin/clamscan -i -f ${LIST_FILE} –remove > $LOG_FILE # If there […]

杀死旧的PHP cron脚本

运行ps aux |之后 grep的PHP,我发现约一个星期前开始的Cron运行的10个PHP脚本,并挂起。 每个脚本通常需要40秒才能完成。 我已经设置了ini_set('max_execution_time',60)希望在60秒后终止。 我如何诊断发生了什么? 谢谢

如何在crontab中使用.profile别名

我已经阅读了这个问题的答案,但仍然不明白该怎么做: 如何在我的crontab中使用我的别名? 我以root身份login到我的Ubuntu服务器。 我在.profile有以下命令: alias test-alias="echo test" 我在我的crontab文件中有以下命令: 11 9 * * * source /root/.profile; test-alias > /root/tmp.output 2>&1 当此命令运行时, tmp.output唯一的输出是: /bin/sh: 1: test-alias: not found 我在这里做错了什么? 我如何在我的crontab文件中使用我的test-alias ? 我想直接在命令中使用别名,我不想创build额外的脚本来运行别名。

运行cron时出错:孙子#10010失败,退出状态2:1时间(s)

在最近几周里,我在debian 6服务器上多次看到这种types的错误。 我看到了不同的退出状态,1,2,25,255 Errors when running cron: grandchild #10010 failed with exit status 2: 1 Time(s) grandchild #10042 failed with exit status 2: 1 Time(s) grandchild #10062 failed with exit status 2: 1 Time(s) grandchild #10080 failed with exit status 2: 1 Time(s) 要么 Errors when running cron: grandchild #23015 failed with exit status 25: […]