crontab

cronjob. run php only in a specified interval of time

跟風遠走 提交于 2019-12-13 18:21:44
问题 I have set up a cronjob that excutes a php script every 35 minutes. The issue is that I only want it to run from 11 AM to 2 AM the next day. I want this to be automatic without having to add # manually to the crontab. I've tried putting something like this at the top of the php script : $time = date(H); if ($time < 23 & $time > 11) { echo 'Working'; } else { echo 'Stopped'; } But as you can see that only works on the same day. NOTE The server is using another time zone which has +4 hours of

Use Session in Cronjob (Crontab)

送分小仙女□ 提交于 2019-12-13 14:16:57
问题 Hi is it possible to use sessions in a cronjob? The Script I use is: session_start(); if(empty($_SESSION['startwert'])){$startwert = 0;} else {$startwert = $_SESSION['startwert'];} if(empty($_SESSION['zielwert'])){$zielwert = 10000;} else {$zielwert = $_SESSION['zielwert'];} .... $_SESSION['startwert'] = $zielwert; $_SESSION['zielwert'] = $zielwert + 10000; echo "Startwert: ".$_SESSION['startwert']."<br>"; echo "Zielwert: ".$_SESSION['zielwert']."<br>"; But the Cron allways start set

cron tab not working php

╄→гoц情女王★ 提交于 2019-12-13 11:28:46
问题 I added a cronjob by entering this command - crontab -e. I added the following tasks in that file- */5 * * * * /var/www/web/vendors/shells/aggregated_deals.php */5 * * * * /var/www/web/vendors/shells/deals.php These are php scripts. after that i restarted the apache server,but these scripts are not executing. And syslog log file is empty. please help me to run this cron. 回答1: I don't think that will run by itself - you need to run the scripts using the PHP interpreter, like this: /usr/bin/php

Send emails with pdf attachment in Magento Cronjob

十年热恋 提交于 2019-12-13 06:27:08
问题 I have a report.phtml that I render to create a PDF file and send it to some email every month. I am trying to automate the process with Magento Cronjob. I know Magento has built-in feature to handle cronjobs but that solution involves a model. I tried to render the report in model but I get nothing. class MyModule_Model_Report extends Mage_Core_Model_Abstract { public function generateReport() { $content = $this->getLayout()->createBlock( 'Mage_Core_Block_Template', 'mymodule.report', array(

cron job to send ip of BeagleBone Black (at every reboot) to my email is not firing

自古美人都是妖i 提交于 2019-12-13 06:25:37
问题 I wrote a simple python script which, when executed, gets my BeagleBone Black's ip address and sends it to my email address, preventing me from having to plug the board into my laptop, get the ip, unplug it, and then remotely SSH in. Here is the script #!/usr/bin/python """Find own ip address and email it.""" import socket import datetime, time import sys failed = 1 while(failed): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8",80)) my_ip = s.getsockname()[0] s

Get the load, cpu usage and time of executing a bash script

自作多情 提交于 2019-12-13 05:09:55
问题 I have a bash script that I plan to run every 5 or 15 mins using crontab based on the load it puts on server. I can find time of running the script, but load, memory usage and CPU usage I am not sure how to find. Can someone help me? Also any suggestions of rough benchmark that will help me decide if the script puts too much load and should be run every 15 mins and not 5 mins. Thanks in Advance! 回答1: You can use "top -b", top gives the CPU usage, memory usage etc, Insert these lines in your

Linux下的crontab定时执行任务命令详解

微笑、不失礼 提交于 2019-12-13 03:48:29
在LINUX中,周期执行的任务一般由cron这个守护进程来处理[ps -ef|grep cron]。cron读取一个或多个配置文件,这些配置文件中包含了命令行及其调用时间。 cron的配置文件称为“crontab”,是“cron table”的简写。 一、cron服务   cron是一个linux下 的定时执行工具,可以在无需人工干预的情况下运行作业。   service crond start //启动服务   service crond stop //关闭服务   service crond restart //重启服务   service crond reload //重新载入配置   service crond status //查看服务状态 二、cron在3个地方查找配置文件: 1、/var/spool/cron/ 这个目录下存放的是每个用户包括root的crontab任务,每个任务以创建者的名字命名,比如tom建的crontab任务对应的文件就是/var/spool/cron/tom。一般一个用户最多只有一个crontab文件。 三、/etc/crontab 这个文件负责安排由系统管理员制定的维护系统以及其他任务的crontab。 SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/

different results out of crontab and manual run

℡╲_俬逩灬. 提交于 2019-12-13 03:37:18
问题 I am running a python script to load some data into db2 database. Yet, I came up with the following module-loading error: Traceback (most recent call last): File "myscript.py", line 22, in ? import DB2 File "/opt/freeware/lib/python2.3/site-packages/DB2.py", line 12, in ? import _db2 ImportError: Could not load module /opt/freeware/lib/python2.3/site-packages/_db2.so. Dependent module libdb2.a(shr.o) could not be loaded. Could not load module libdb2.a(shr.o). System error: No such file or

系统管理之资源与定时任务

别等时光非礼了梦想. 提交于 2019-12-12 23:18:59
一、系统资源查看相关命令 1、vmstat 命令监控系统资源 [root@centos ~]# vmstat 1 3 #每一秒刷新一次,共刷新三次 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 329960 21424 49564 0 0 324 34 84 140 1 2 91 6 0 0 0 0 329928 21424 49560 0 0 0 0 26 29 0 0 100 0 0 0 0 0 329928 21424 49560 0 0 0 0 27 32 0 0 100 0 0 procs:进程信息字段: r:等待运行的进程数,数量越大,系统越繁忙。 b:不可被唤醒的进程数量,数量越大,系统月繁忙 memory:内存信息字段: swpd:虚拟内存的使用情况,单位 KB。 free:空闲的内存容量,单位 KB。 buff:缓冲的内存容量,单位 KB。 cache:缓存的内存容量,单位 KB。 swap:交换分区的信息字段: si:从磁盘中交换到内存中数据的数量,单位 KB。 so:从内存中交换到磁盘中数据的数量,单位 KB

Cron job in Ubuntu

孤人 提交于 2019-12-12 21:15:51
问题 This should be pretty straight forward but I can't seem to get getting it working despite reading several tutorials via Google, Stackoverflow and the man page. I created a cron to run every 1 min (for testing) and all it basically does is spit out the date. crontab -l * * * * * /var/test/cron-test.sh The cron-test file is: echo "$(date): cron job run" >> test.log Waiting many minutes and I never see a test.log file. I can call the "test.sh" manually and get it to output & append. I'm