crontab

How to set up a cron job to run an executable every hour?

半世苍凉 提交于 2019-11-28 03:44:37
I need to set up a cron job that runs an executable compiled using gcc once every hour. I logged in as root and typed crontab -e Then I entered the following and saved the file. 0 * * * * /path_to_executable However, the cron job does not work. I see that when I type /...path_to_executable I get a segmentation fault. I can only execute the executable from the folder it is located in. Is there a way I can solve this problem? 0 * * * * cd folder_containing_exe && ./exe_name should work unless there is something else that needs to be setup for the program to run. David Thornley The solution to

Crontab - Run in directory

故事扮演 提交于 2019-11-28 03:07:15
I would like to set a job to run daily in the root crontab. But I would like it to execute it from a particular directory so it can find all the files it needs, since the application has a bunch of relative paths. Anyway, can I tell crontab to run from a particular directory? Gilles All jobs are executed by a shell, so start that shell snippet by a command to change the directory. cd /path/to/directory && ./bin/myapp Concerning the use of && instead of ; : normally it doesn't make a difference, but if the cd command fails (e.g. because the directory doesn't exist) with && the application isn't

PHP function that receive a cron string and return the next run timestamp

我是研究僧i 提交于 2019-11-28 02:46:43
问题 I need to develop a task system that should be able to work on servers that doesn't support crontab. I'm asking if there is any existing code that can take a cron string (e.g. '0 0,12 1 */2 *' and return the timestamp of the next scheduled run. If such a code couldn't be found then how should I start with that? 回答1: You could use this class PHP-Parse-cron-strings-and-compute-schedules It'll also compute the last scheduled run 回答2: Use this function: function parse_crontab($time, $crontab) {

Restarting cron after changing crontab file?

柔情痞子 提交于 2019-11-28 02:37:52
Do I have to restart cron after changing the crontable file? leonbloy No. From the cron man page : ...cron will then examine the modification time on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified But if you just want to make sure its done anyway, sudo service cron reload or /etc/init.d/cron reload Sheldmandu On CentOS with cPanel sudo /etc/init.d/crond reload does the trick. On CentOS7: sudo systemctl start crond.service Gyro I had a similar issue on 16.04 VPS Digital Ocean. If you are changing crontabs, make sure to run

crontab配置

南笙酒味 提交于 2019-11-28 02:33:22
crontab的语法:    crontab各参数说明:   -e : 执行文字编辑器来编辑crontab,内定的文字编辑器是VI   -r : 删除目前的crontab   -l : 列出目前的crontab(查看专用)   -i : 会和-r 配合使用,在删除当前的crontab时询问,输入y 则删除   注意crontab是分用户的,以谁登录就会编辑到谁的crontab    crontab特殊的符号说明:   "*"代表所有的取值范围内的数字。特别要注意哦!   "/"代表每的意思,如"*/5"表示每5个单位   "-"代表从某个数字到某个数字   ","分散的数字   crontab文件的使用示例:   30 21 * * * 表示每晚的21:30   45 4 1,10,22 * * 表示每月1、10、22日的4 : 45   10 1 * * 6,0 表示每周六、周日的1 : 10   0,30 18-23 * * * 表示在每天18 : 00至23 : 00之间每隔30分钟   0 23 * * 6 表示每星期六的11 : 00 pm   * */1 * * * 每一小时   * 23-7/1 * * * 晚上11点到早上7点之间,每隔一小时   * 8,13 * * 1-5 从周一到周五的上午8点和下午1点   0 11 4 * mon-wed

cron job with CakePHP

匆匆过客 提交于 2019-11-28 01:58:22
问题 I have referred http://bakery.cakephp.org/articles/view/calling-controller-actions-from-cron-and-the-command-line and created cron_dispatcher.php and placed it in the app folder. I have return some test email function for the cron job to run in my users controller's test method. And i have created a Cron job in my web server's control panel like "/usr/bin/php/home4/enventur/public_html/pennystock/cron_dispatcher.php /users/test" But its giving me an error as "No input file specified." Please

Percent sign % not working in crontab

有些话、适合烂在心里 提交于 2019-11-28 01:53:04
I have a cron issue with curl : curl -w "%{time_total}\n" -o /dev/null -s http://myurl.com >> ~/log works great and add a line in log file with total_time. But the same line with cron doesn't do anything. It's not a path problem because curl http://myurl.com >> ~/log works. fedorqui % is a special character for crontab . From man 5 crontab : The "sixth" field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or a "%" character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. A "%"

Starting phantomJS from a script in a cronjob

最后都变了- 提交于 2019-11-28 00:16:35
问题 I'm running a python script through a cronjob. I have a virtual environment and in the cronjob I'm running it through this virtual environment. When I run the script normally phantomJS starts as it should, but running it through a script in a cronjob I get this error. What is missing in the cronjob to be able to start phantomjs? Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen Traceback (most recent call last): File "/home/scraper/superfish-extension

shell之磁盘容量检查,配合crontab可以定时清理磁盘

雨燕双飞 提交于 2019-11-28 00:05:34
我的做法: !/bin/bash Available=`df -k | sed -n 2p | awk '{print $4}'` if [ $Available -eq 0 ];then `echo '' > /home/wwwlogs/bes-req.log` fi 参考资料: #!/bin/bash #取得每个分区的使用百分比(不要百分号) percent=`df -k | grep -v Filesystem| awk '{print int($5)}' ` #循环判断分区使用率是否超过90% for each_one in $percent do #判断使用率是否超过90% if [ $each_one -ge 90 ];then #如果超过90 则把使用情况发给mail_address mail_address换成你的邮件地址 df | mail -s "Disk Critical" mail_address fi done 配合shell 的crontab功能,不能写java代码就可以迅速实现功能 一 cron crond位于/etc/rc.d/init.d/crond 或 /etc/init.d 或 /etc/rc.d /rc5.d/S90crond,最总引用/var/lock/subsys/crond。 cron是一个linux下的定时执行工具