Response
stringlengths
8
2k
Instruction
stringlengths
18
2k
Prompt
stringlengths
14
160
0,12 * * * yourcommandexecutes your command at 0 and at 12 o'clock.*/12 * * * * your commandwould execute your command every 12 minutes each hour.
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.Closed10 years ago.Improve this questionHow can I run command every twelve hours every day? Tried this not working :/12 * * * * * mycommand
How can I run command every twelve hours every day? Tried this not working : /12 * * * * * mycommand [closed]
If a file name is given as the sole argument to thecrontabcommand, it is used to replace the current crontab:crontab -l > cron.jobs crontab cron.jobsAlternately, feed the file through stdin:crontab < cron.jobs
One of our servers has around 20-25 different cron jobs scheduled on it. Usually, we periodically check-in the cron jobs to a file in the repo usingcrontab -l > cron.jobsWhile bringing up a new server, which is a replica of the previous server (in terms of OS and deployed code base), is it possible to source the cron jobs for the new server from a file containing valid cron jobs?
Is there a way to source cron jobs from a file
You could do something like this:In your mysql host machine:1- Create a .sh file 2- Inside of this sh, put: - mysqldump -u myuser -p mypass mydatabasename > mydumpfile.sql - scp mydumfile.sql user@remote_host:remote_dir 3- Add that sh to a cron Job, to a daily execute (or something that meets your requeriments)In the remote machine:1- One sh script that look for a file(mysqldumpfile.sql) in the specific dir 2- This line : mysql -u remotemysqluser -p remotemysqlpass database < mydumpfile.sql 3- rm mydumpfile.sql 4- Add this sh on a daily cron 1 or two hours past the host cron.
Ok first off this is not a backup job, and I know about using phpmyadmin and so on.What I have is a Live server and a TEST server, People work on the live one, constantly modifying it. I want the database on the LIVE server to be copied to the TEST server every night.Does anyone have a php script I could run either to copy down the whole thing (or at least specific tables)? I'm not that confident with using the command line so if there is a way of doing it that way I could do with some pretty specific instructions :PI have dug around but everyone seems to be suggesting doing it manually or by using third party tools.Any help much appreciated.
Copy a mysql database from one server to another PHP cron Job automated
Just create a bash script for this:/home/emre801/run.sh#!/bin/bash source /home/emre801/.bashrc pb switch 2.7.3 pb /full/path/to/your/code.pymake it executable:$ chmod 755 /home/emre801/run.shAnd add it to the crontab:*/10 * * * * /home/emre801/run.shor*/10 * * * * bash /home/emre801/run.sh
Let me start out by saying I'm extremely new to using python and creating a crontab.Basically have a custom Python environment created on my dreamhost account using this tutorialhttp://wiki.dreamhost.com/Python#Automatic_InstallationRunning python script is easy after this. Normally I just type this whenever I have a new session.source /home/emre801/.bashrc pb switch 2.7.3Then I just run any python script using thispb py code.pyThe issue is when I try to create a crontab, I have this right now in my crontab.*/10 * * * * source /home/emre801/.bashrc; pb switch 2.7.3;pb py code.pyThis code emails me the following output/bin/sh: pb: command not foundMy question is how can I set it up the source correctly to not give me this error?Any help is greatly appreciated
Creating a crontab to run Python on Dreamhost
Normally, the whole point of runningwgetis to create an output file. A URL likehttp://www.example.comtypically resolves tohttp://www.example.com/index.html, so by creatingindex.html, thewgetcommand is just doing its job.If you want to runwgetanddiscardthe downloaded file, you can use:wget -q -O /dev/null http://www.example.comThe-o /dev/nulldiscards log messages;-O /dev/nulldiscards the downloaded file.If you want to be sure that anythingwgetwrites to stdout or stderr is discarded:wget -q -O /dev/null http://www.example.com >/dev/null 2>&1In a comment, you say that you're using thewgetcommand to "trigger items on yourcroncontroller" using CodeIgniter. I'm not familiar with CodeIgniter, but downloading and discarding an HTML file seems inefficient. I suspect (and hope) that there's a cleaner way to do whatever you're trying to do.
I've noticed that my cron outputs are creating index.html files on my server. The command I'm using iswget http://www.example.com 2>&1. I've also tried including--reject "index.html*"How can I prevent the output from creatingindex.htmlfiles?--2013-07-21 16:03:01-- http://www.examplel.com Resolving example.com... 192.0.43.10 Connecting to www.example.com|192.0.43.10|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 0 [text/html] Saving to: `index.html.9' 0K 0.00 =0s 2013-07-21 16:03:03 (0.00 B/s) - `index.html.9' saved [0/0]
Cron output to nothing
The format is:+---------------- minute (0 - 59) | +------------- hour (0 - 23) | | +---------- day of month (1 - 31) | | | +------- month (1 - 12) | | | | +---- day of week (0 - 6) (Sunday=0 or 7) | | | | | * * * * * command to be executedSo in your case being* 1 * * * /path/to/my/simpleJob.shit means at hour 1, any minute.To have it workingjustat 1.00, change it to:0 1 * * * /path/to/my/simpleJob.sh
I have an interesting problem with a cron job. I'm on a server with Cent OS and we're using Vixie cron. All this is very straighforward and i have a backup job that i want to run once every day at 01.00, so i created this simple crontab entry:* 1 * * * /path/to/my/simpleJob.shWhat happens is this: at 01.00.02, the job runs as expected. Then cron (or something) continues to run the job every minute. Can anyone out there help me out? I have no idea what might be the root cause for this./M
Cron not working as expected
Try this expression0 0 12-23,00-12 ? * FRI,SATand you can verify the next scheduled time here athttp://www.cronmaker.com/by entering this expression.
I need cron expression which allows to me run scheduler by the following rules:Starts 12:00 am on Friday (pacific time) ends 12:00 am on Saturday (pacific time) And between these two dates it must occurs every houri can write something like"0 0 12/1 ? * FRI-SAT"but ofcourse it is not correct. How to set simple range from 12-00 FRI to 12-00 SAT?
Cron expression for one day occurs every hour
try this0 0 1 ? 1/1 SUN#1 *it will run at 1 PM every first sunday of month
I have a cron line for running a command each first Sunday of the month, which looks like this:0 19 1-7 * 0 command.sh Minutes=0 Hours=19 Day= 1st to 7th * = any month 0 = first day of the week (Sunday)However, I had the surprise command.sh has run last Sunday (16th of June). Can anyone explain why my cron line is mistaken?As an alternative, according to awiki page, it is possible to use the "#" character to: "allow you to specify constructs such as "the second Friday" of a given month" . Is there an example available as how to use this to fit "the first Sunday of a given month"?
Cron for job to run on first Sunday of the month
Here's how you can call a task from an action, you just need to add a link to it and you'll be good. I've used the standard Symfony 'Clear Cache' task in the example, but you can change it to yours:public function executeRunTaskTest(sfWebRequest $request) { // need to be working in the project root chdir(sfConfig::get('sf_root_dir')); // init the task we want to run $task = new sfCacheClearTask($this->dispatcher, new sfFormatter()); // run the task $task->run( array(), // array of arguments array( 'app' => 'frontend', 'env' => 'prod', 'type' => 'all', ) // array of options ); // back to where we came from $this->redirect($request->getReferer()); }You could also use the PHPexec()orshell_exec()functions, but this Symfony solution is probably easier. :)
I have a cron task placed under myProject/lib/task. This cron works daily for over a year.However now I have to create a button inside my project to do the same process as the cron whenever my client needs. The code is too complex and I can't rewrite everything on a normal action.Is there a way to call a cron task from a normal action?
Manually call a cron task Symfony 1.4
You can see syslog to find out what happened, seems like invalid command arguments or invalid crontab file format.
My crontab is not working right.. I don't know why, I first stumbled across the time being wrong but now I do date, then set it up 5 minutes ahead and 10 minutes later still nothing happened.. anyone any idea's?My crontab:0,10,20,30,40,50 * * * * /usr/local/bin/flexget -c "/home/user/NASDM/FlexGet/config.yml" --cron 01 08 * * * /usr/bin/find /home/user/USBHD/Movies/ -mtime '-1' -exec cp {} /home/user/NASVD/Movies \; 40 13 * * * PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/lib; perl /home/user/NASDM/unrar/unrar2.pl --conf="/home/user/NASDM/unrar/conf/unrar-data-conf.pl" --cmd=unrar 35 13 * * * /usr/bin/find /home/user/NASVD/Movies/ -iname "*sample*" -exec rm {} \; 36 13 * * * /usr/bin/find /home/user/NASVD/Series/ -iname "*sample*" -exec rm {} \;[email protected]I don't get an email neither.. If I execute every command in ssh it works great but when I let crontab do it it doens't do shit.. anyone any idea's???I ran pgrep cron, this gives me back 2899..I ran date before the crontab should work this gave me: Sat Jun 8 13:34:34 CEST 2013I really don't get it where I go wrong.. Please any help is welcome!NOTE: The first command works all the time every day every hour!! I never had to worry about flexget..EDIT:::::::::: Found the problem! My cronjob/system date was 9 hours earlier then the normal date in debian. Don't know how this is possible but it doesn't matter since I now know it :)
Crontab not working like it should
You will need to contact the server in any case, so you might as well pull.If you are on the current branch when you pull, and want to detect whether the current branch has changed, you can always do (note: written in shell)BEFORE=$(git rev-parse HEAD) # git pull here AFTER=$(git rev-parse HEAD) # Changes if $BEFORE is different from $AFTER
I have a server deployed. I am writing a crontab task. It uses a python script that need to check if there is new push into the repository. If it finds a new push, it will pull and update the server code and should restart the server.My problem is how to make the python script know if there is new commit into the repository?I know you can usegit rev-list deployment..origin/deploymentto check if there is any commit is available on the remote server.But how to implement in the python script and make it decide to know that it need to pull?Thanks Nick
crontab automated git pull
Your command wget simply sends a GET request to the URL specified.2> /dev/null -> send errors to /dev/null (means send to nothing).So errors are not logged.
I havewget -O /dev/null http://example.com/job.php 2>/dev/nullHowever I don't know what does it really mean? The only thing I know is that it uses the application called wget and one of the parameters is the page that I want to run. The other things, I have no idea.-O /dev/nulland2>/dev/null?Note: This is from a cPanel running on FreeBSD.
Running a PHP page every minute with CronJob
Run this to find the directory:<?php print __FILE__; ?>Try this:* * * * * php /var/www/clients/client2/web6/web/global/cron/cron.phpThis is how my crons work on my website.
I'm trying to set up a cronjob which sends me an email when it runs.when I execute the file using a ssh command via PuTTY, it works, it also works when I set it up as an URL, but doesn't work when setting using absolute path.Here is what all I've tried till now : Does work :* * * * * http://example.com/cron/cron.phpDoesn't work :* * * * * php /var/www/clients/client2/web6/web/global/cron/cron.php * * * * * /var/www/clients/client2/web6/web/global/cron/cron.php * * * * * /usr/bin/php /var/www/clients/client2/web6/web/global/cron/cron.phpAll 3 that I listed in 'doesn't work' works when executed as commands through PuTTYFile permissions are all sorted out and are 777 for the cron file, and the directory it resides in.I'm using IspConfig3 and Debian and Apache2, if that mattersEDIT : here's the code in cron.php :#!/usr/bin/php <?php $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Cronjob <[email protected]>' . "\r\n"; mail("[email protected]", "Cronjob Complete - ". date('d-m-Y'), "At".date("H:i:s"), $headers); ?>
PHP CronJob doesn't work
You should read the man page oncrontab: (e.g.man crontab)To edit a crontab, you need to callcrontab -e. This will open the editor defined in theEDITORenvironment variable.crontab -lwill list currently set crontabs. But this does not necessarily mean that the crontab is valid.
Closed.This question isoff-topic. It is not currently accepting answers.Want to improve this question?Update the questionso it'son-topicfor Stack Overflow.Closed10 years ago.Improve this questionI have created a cronjob task list in a cron.txt file. This file contains list of cron jobs to be executed.From this, consider job A should be run 3 times every day, * job B should be run 4 times in a week * job C should be run 8 or 9 times in a month.I have already created a crontab for this to execute in every minute. It gives more load to the server. How to reduce the load for the server? [**Because events will be scheduled 2 or 3 times in a day]. How to schedule a dynamic crontab for this, in Linux Ubuntu?EDIT:Is it possible to schedule a cron in LINUX, based on the value retrieved from the MySQL DB instead of running a crontab in every minute or every hour ?(Can we schedule a crontab dynamically based on the value retrieved from MySQL DB?)Else,We will run a crontab every day midnight to get the schedule times and as per the schedule times, we can run a crontab.[Running a cron in every minute or every hour also some unnecessary loading to the server.]
schedule crontab in ubuntu [closed]
You have what's known asthe XY problemhere.You have a problem with this part of your shell script, and you want to solve the problem by fixing the script. In reality, fixing the root cause of the problem is easier.Simply alter your cron job to run every other Sunday:#----+-----+-----+-----+-----+------------------------------------------------- #min |hour |day |month|day |command # | |of mn| |of wk| #----+-----+-----+-----+-----+------------------------------------------------- 03 04 * * 7 expr `date +%W` % 2 >/dev/null || fortnightly.shSeeHow to instruct cron to execute a job every second week?for more info.
Basically, I have a series of commands I want to run every other sunday. I set a cron task to run the script every sunday, then this script only allows the script to run on even weeks, thus it only runs every other sunday. My question is, will this script still work going from year to year.if [ $(($(date +'%U') % 2)) -eq 0 ] then some command fi
Will this code work over a new year?
You need full path to i2c inside your perl script:$temp = `/full/path/to/i2cget -y 1 0x48 0x0`;
I've read a number of other Q&A's that seem to be related, but haven't been able to track down the issue here.I have the following perl script that I use on my Raspberry Pi. I'm hoping to log temperature data from an I2C sensor to a sqlite3 database. The program below works when being run from the command line but not when run from cron.I'm assuming that the value from i2cget is incorrect when run from cron, but I'm not sure how to figure out what part of my environment i2cget needs to work properly.#!/usr/bin/perl #printf '%d\n' `i2cget -y 1 0x48 0x0` $temp = `i2cget -y 1 0x48 0x0`; #$temp = sprintf("%d\n", $temp); $temp = hex($temp); #print $temp, "\n"; use DBI; #/home/techplex/ece331/project2_temp_data_grapher/ $dbh = DBI->connect( "dbi:SQLite:tempdata.db" ) or die "Cannot connect: $DBI::errstr"; $dbh->do( "CREATE TABLE IF NOT EXISTS temperature (timestamp datetime, temperature float);" ); $dbh->do( "INSERT INTO temperature (timestamp, temperature) VALUES (datetime('now', 'localtime'), $temp);" ); $dbh->disconnect;I've added this line to my crontab:*/1 * * * * cd /home/techplex/temp_data_grapher; ./datalogger.pl
perl program run from crontab yields wrong values i2cget raspberry pi
Not sure what exactly are you trying to achieve, but most probably you want to run this script in Cron, not in Apache.http://en.wikipedia.org/wiki/CronThere are several reasonsnotto use Apache:With Apache, script will be executed on client's request. You never know when the next request is going to happen -- maybe in 5 minutes, maybe in two years.Once script is started, your client will have to wait until the script has finished; this will needlessly increase page load time.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,visit the help center.Closed10 years ago.hello I have a question and would like to know if it is possible to make running a rule in apache with a php script. I will give an example let's say I want to delete images that have more than 1 year registered in the database. then I make a script right? gives leaves it running in apache this check with an interval of 5 minutes?
php script running on apache [closed]
This always works for me...require_once("/full/path/to/your/file/includes.php");
I'm trying to use a PHP script with sensitive information so I'm using includes to host the passwords above the webroot.The script works fine run via the browser, but when I run it as a crob job it generates error messages regarding includes.The open_basedir setting is: /var/www/vhosts/xxx/:/tmp/ -- wondering if that's relevant here?Grateful for any suggestions on how to resolve this or workarounds.PHP Warning: include(../includes.php): failed to open stream: No such file or directory in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6 PHP Warning: include(../includes.php): failed to open stream: No such file or directory in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6 PHP Warning: include(): Failed opening '../includes.php' for inclusion (include_path='.:') in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 6 PHP Notice: Use of undefined constant API_KEY - assumed 'API_KEY' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 88 PHP Notice: Use of undefined constant SCOPE - assumed 'SCOPE' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 89 PHP Notice: Use of undefined constant REDIRECT_URI - assumed 'REDIRECT_URI' in /var/www/vhosts/xxx.com/httpdocs/linkedin_status.php on line 91
Accessing PHP includes above webroot when running as cron job
I ended up usingsupervisordwhich solved all my problems.
If I have a cron job that runs every minute, and the first iterations runs for 62 seconds, will the second iteration wait to start until the first occurance ends, or can it happen that the same cron job runs concurrently?To illustrate this, see scenario 1:|0 |60 |120 |180 |240 |300 ------ Cron Job 1 Taking 60 Seconds --------- Cron Job 2 Taking 90 Seconds ------ Cron Job 3 Taking 90 Seconds but overlapping with the previous cron jobIs the above what will happen, or will scenario 2 happen:|0 |60 |120 |180 |240 |300 ------ Cron Job 1 Taking 60 Seconds --------- Cron Job 2 Taking 90 Seconds XXX-------Cron Job 3 waiting til the next 1 minute interval startsMy concern is that there will be a period for 30 seconds marked XXX where there will be NO cron job running.What am I trying to accomplish? I want to execute a PHP script every single second, indefinitely. It doesn't have to run once a second, but it must RUN, END, RUN, END, RUN, END. If an iteration takes 5 seconds, it must only start the next one after the first has ended. But it must never ever stop. The problem is that I can't determine the length of an iteration. One iteration could take 1 second, or it could take 5 seconds, or even longer.Can cron do this? So that I can be guarenteed that the script will run every single second no matter what?If not, how can I gaurentee that a PHP script runs indefinitely, one iteration after the other?
PHP: How to use cron (or another method) to get a PHP script to run every second?
How do I get a script to execute autonomously at 23:59 each day?cronis the tool for the job.You would have an entry that looks like59 23 * * * /path/to/my_script.shWhich means to run/path/to/my_scriptevery day at 23:59.
How do I get a script to execute autonomously at 23:59 each day?I figured using anifstatement would work but how would I get a script that hasn't been executed yet to know when I want it to work?If I were to run it first thing in the morning, is there some sort of entry I can use to keep the program alive until 23:59 where I can tell it to run it again at the given time? That way it would only replace the file from earlier and give me a summarized report of the daily activity and I wouldn't have to write multiple scripts.
Autonomous scripting
I've had problems calling both python and perl directly from cron. For perl it boiled down to LIBPATH defaulting to something insufficient.I'd suggest wrapping your commands in a shell script and adding "set -x" to trace through the problem#!/bin/sh set -x export PYTHONPATH=/my/python/modules:$PYTHONPATH /usr/bin/python /home/pi/myst-myst/myst.py $(/home/pi/myst-myst/monitor.sh)Call it directly to make sure it works, and then try calling via cron. Make sure to redirect both stdout and stderr to capture any error messages*/10 * * * * /home/pi/myscript.sh > /home/pi/stdout 2> /home/pi/stderr
I'm trying to get cron to run this command every 10 minutes;(In /home/pi/myst-myst/ DIR)python myst.py `./monitor.sh`I've tried pretty much everything to get it to work but cron won't execute it properly. Here is what I have at the moment;*/1 * * * * /usr/bin/python /home/pi/myst-myst/myst.py `./monitor.sh`Any help would be much appreciated.Is there an alternative to crontab I could use? Could I use a bash script to execute python and then use a cron for that bash script?
Crontab Issues running Python
The cron configuration rule is not a shell command (although it ends with one).You have to enter it into your cron configuration, not enter it at the command prompt.Runcrontab -eto edit your cron configuration.
I have .sh file on redhat to run a crontab. Content of this file#!/bin/bash echo "run every 1min..."I run it with the command:[root@localhost ~]# * * * * * /var/www/html/ac/bc/1.sh bash: anaconda-ks.cfg: command not found
Cannot run crontab on Redhat
Here is how tooverwritethe log file:* * * * * /home/vas/servers/tomcat/myTest.sh > home/vas/servers/tomcat/myTest.logvs how toappendto the log file:* * * * * /home/vas/servers/tomcat/myTest.sh >> /home/vas/servers/tomcat/myTest.log(edit, based on your comment)Can you try something like this:chmod 771 /home/vas/servers/tomcat/myTest.shAnd then dols -al /home/vas/servers/tomcat/myTest.shto be sure you have set permissions correctly.
I want to run the simple java program called from crontab. As I want to know whether the crontab is running properly, I want to print out the result as log file.For now, I don't know the crontab is running my java program correctly or not.Sample Java program:public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println("hello" + c.getTime()); }Sample sh:#!/bin/bash JAVA_HOME=/usr/java/jre1.6.0_31/ export JAVA_HOME; for file in /home/vas/servers/tomcat/myTest.jar do CLASSPATH=$file:$CLASSPATH done export CLASSPATH $JAVA_HOME/bin/java myTestCrontab:* * * * * /home/vas/servers/tomcat/myTest.sh > /home/vas/servers/tomcat/myTest.log 2>&1PS: myTest.java, myTest.sh are all located under /home/vas/servers/tomcat/Edited: include / in front of home.=========================================================Now I can see the log file , but it was saying that [ /bin/sh: /home/vas/servers/tomcat/myTest.sh: Permission denied ] .
log result of java program that run from crontab [ Permission denied ]
Your sending logic (scheduling, throttling etc.) should really be handled in the application itself, and not via cron. If you move the logic to the application, you can setup a cronjob to run your app script every 10 minutes and it will only send the emails when the time is appropriate and the the application tells it to send.
I have the need of running a script 5 times every other wednesday. What further complicates it, is that the script needs to have a pause of atleast 1 hour between each run, 1 hour 10 minutes would be good.I need this pause because its a newsletter sender, it sends alot of emails, and the mail-limit of the server is 3000 emails every hour.So examples of when the script should run:Wednesday February 20th at 10.00, 11.10, 12.20, 13.30, 14.40. Wednesday March 6th at 10.00, 11.10, 12.20, 13.30, 14.40. Wednesday March 20th at 10.00, 11.10, 12.20, 13.30, 14.40. Wednesday April 3th at 10.00, 11.10, 12.20, 13.30, 14.40.and so on.Is it possible at all, or should i solve it some other way?
how to set up a cronjob to run 5 times every other wednesday?
You have to tell cron where to find the X server if the command you run uses it.So use:env DISPLAY=:0.0 xeyesorexport DISPLAY=:0.0; xeyes.Some cron implementations (Debian, Ubuntu, ...) allows to set enviroment simply in cron file.DISPLAY=:0.0 # m h dom mon dow command */1 * * * * xeyes
I have following line in crontab */1 * * * * xeyesit does not show any xwindow but on the contrary */1 * * * * touch somefile.txt works fineTried to search on google but didnt get any specific answers!!
cron job not working for xwindow
To run once every two hours:0 */2 * * * <command-to-run>So it's running once a minute from 12am to 12:59, then from 2:00am to 2:59, ... etc.http://livecronjobs.com/how-to-run-cron-every-2-hour
The scriptdeployment_worker.shis a control script in charge of stopping and starting a service each two hours... or so I think. Apparently this line in the crontab does something else, judging by the fact that the process comes back from hell pretty fast whenever I kill him:* */2 * * * /srv/server_ctrl/deployment_worker.sh restartIn line 45 ofdeployment_worker.sh:echo "Issuing service start" >> $CONTROL_LOGI issue a line to the log file, and that line effectivelyappearsin the log, which I think it means this file gets executed by somebody (not me!)... and the only one that comes to my mind is the cron daemon ....So, here are my questions:What the above crontab line do?
What does this crontab line do?
Indeedcroncould be an answer to your question. It is a special program that is in Linux systems and runs defined programs/commands on given time or periodically. Look here:http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
I am trying to execute a PHP script at the predefined time. For instance, how can I write a php script that will force that script to be run on March 24th, 2013 at 11:14am(even if the browser is closed). I heard about cron but it is not clear to me.Thank you for reading
PHP auto execution
You should not be using runserver to serve your application in production. You should use a real webserver, for example Apache. That will automatically start up on reboot.
Basically i am Django developer so i have just working knowledge in LinuxI have a django app running onEC2.Now here is the problem suppose if i am restarting the ec2 my django app need to be run again .I don't want to run the django server again and again .So i tried to put this process in cronjob like@reboot cd /path/to/dir/./manage.py runserverUnfortunately it is not working .What might problem is here ?Please tell me the way to run Django application at system booting .
Django : Run Django at system boot
This is often done by setting up a cron job to call a rake task. In the rake task you can call Rails code easily.There are lots of examples on the web. Here's one from SO:A cron job for rails: best practices?EDIT -- adding Resqueue code and Mailer examplesuser.rbclass User scope :birthday_today, lambda { where('birthday = ?', Date.today) } def self.send_birthday_alerts self.birthday_today.each do |user| BirthdayAlertJob.enqueue(user.id) end end def get_primary_email ... end endjobs/birthday_alert_job.rbclass BirthdayAlertJob @queue = :birthday_alert def self.perform(u_id) user = User.find(u_id) UserMailer.birthday_alert(@user).deliver end endschedule.rbevery 1.day, :at => "8:00pm" do rake "users:send_birthday_alerts" endusers.rakenamespace :users do desc "Queue up Birthday Alerts" task :send_birthday_alerts => :environment do User.send_birthday_alerts end enduser_mailer.rbclass UserMailer < ActionMailer::Base def birthday_alert(user) mail(to: user.primary_email, subject: "Happy Birthday") ... end endThis is close, untested, etc. One thing I know you'll need to do, is make sure the user hasn't already been sent an email. Not sure how you're doing this now. Another column could hold the last time the alert was queued.
I have a method that i created calledget_primary_email(user)and it's in my application_controller.rb file.Now i use this method in both my app, as well as a cron job that calls a method which usesget_primary_email(user)My problem is, if i leave the method defined as this:def get_primary_email(user) endIt works just fine in my app, but the cron job errors out.If i define the method as this:def self.get_primary_email(user) endmy cron job works, but every method that calls get_primary_email(user) through a browser fails.How can i use this same method in both places?EDITschedule.rbset :output, "#{path}/log/cron.log" every 1.day, :at => "8:00pm" do runner "BirthdayRemindersController.send_birthday_email_reminders" end
Rails how to create a method that can be used via browser and cron job
In Oracle 10+ DBMS_Scheduler has a window definition that does exactly what you want. When the window ends, processing of running jobs can be terminated.http://docs.oracle.com/cd/E14072_01/appdev.112/e10577/d_sched.htm
I have not yet coded a potential solution to this, so before anyone asks I have zero code to back this up as I am trying to get a firm grip on the processing behind what needs to happen.My problem is that I have an Oracle database that will be firing off jobs constantly (every 10 minutes or so) and I need a safe way (security wise and data integrity wise), to terminate these jobs and prevent them from executing while a nightly back up takes place. For the sake of discussion this will be done via a cron job. The way I think it should work is that the cron job will fire off at a time of 1 am (or some other low usage time, by low I mean < .001% of the user base will be interacting with the system). The java process will need to execute some PL/SQL function on the database that does the following things:1) A force terminate on all running jobs 2) A snapshot of data that is to be written to an arbitrary directory 3) Restart all jobs (mark them as enabled instead of disabled)My question is this:How can this be accomplished with the minimum amount of permissions and does this loose architecture facilitate the ability to prevent data corruption, assuming Oracle is correctly generating undo/redo logs? IF this is an insecure/poor way of doing this, any other suggestions are appreciated.
Strategy to terminate database job from a remote program utilizing cron
Just create a shell script thus:#!/bin/bash scp username@host:file.log file.log.`date +%H%M%S`(error checking elided - don't forget to make it executable viachmod u+x)The date invocation takes the current date/time, creates a timestamp and appends it to the destination log file name. So you'll get something like:file.log.131504That's time-based, but you'll likely want a date instead. For more info seehereand thedate man pagefor formatting options.Note that jobs under cron run with a cut down environment (reduced PATH etc.). So be sure to set all appropriate environment variables in your script, cd to the correct directory etc., and log the results via something like:* * * * * /home/user/mycronscript.sh 2>&1 >/tmp/test.log
I'm a programming apprentice and have recently been given a job to complete on the terminal and I need some help or just some pointers in the right direction as to what I need to do.I need to copy a certain file from a remote server and back it up every hour with a time stamp included. I know how to connect to servers using SSH and I also know how to transfer files using SCP - it's just writing the script I need some help with. I know that I will need to use CRON to schedule it I just don't know how I can put everything together. I'm using the latest version of Ubuntu.Any help would be much appreciated.Thanks.
How can I schedule a script to copy a file from a remote server to my local machine every hour with a time stamp using CRON & SCP?
That's thevieditor, your default text editor (checkman vi). Here are the commands to edit your crontab withvi:Ctrl-cyour/usr/local/bin/php Import_Product_Data.php.Move the cursor to the first empty linePressiinto theviconsolePaste using your mouse.HitESC.Write:wq.HitRETURN.
I have a php script I'm trying to run using a cron job. I can execute the script from CLI doing/usr/local/bin/php Import_Product_Data.phpSo I have tried..0 0 * * * /usr/local/bin/php Import_Product_Data.phpandcrontab 0 0 * * * /usr/local/bin/php Import_Product_Data.phpandcrontab -e 0 0 * * * /usr/local/bin/php Import_Product_Data.phpVince V. saysto open your cronfile and do it.. When I entercrontab -e, I get*/5 * * * * /root/autosvnup.sh ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "/tmp/crontab.ZBGTFu" 1L, 31CThen I get stuck and not sure what to do.. Would someone help me out?
How to add a cron job to run php script
Check this outhttp://railscasts.com/episodes/164-cron-in-ruby(there is a revised version, but you have to pay $9 aprox. per month for pro videos).You can make a task or a runner so you can access to ActiveRecord and store the data into some model.For runners in Rails:http://guides.rubyonrails.org/command_line.html#rails-runnerFor tasks:http://erik.debill.org/2011/12/04/rake-for-rails-developersAlso, if you use tasks (which I recommend) watch this entry:Do rails rake tasks provide access to ActiveRecord models?
I need to store data from a cron job in Ruby on Rails so that my controllers can still access it. I'm not too sure what the best way is to do this. By the way I'm a Ruby on Rails newb, so perhaps what I'm asking is extremely simple.
How to store cron job results in RoR
So when crontab runs the shell script, the backup_(date).sql file is actually saved under the /root folder.Running the shell script manually places the SQL file where the shell script is.
Hopefully I am posting it in the right forums..Basically, I am trying to run a script that will do a MySQL database dump which works when I run it manually, but crontab doesn't seem to run that particular script for some reason.My crontab is setup as such (for testing purposes, running every minute):* * * * * /opt/lampp/htdocs/xyz/backup/backup.shThe script is setup as such:#!/bin/bash # Script to backup the database /opt/lampp/bin/mysqldump -u root xyz > backup_$(date +%Y%m%d).sql echo " backup_$(date +%Y%m%d)" > /opt/lampp/htdocs/xyz/backup/log.txtI know the script runs, because the log.txt is created. But for some reason, no SQL file is generated. I also know that the line/opt/lampp/bin/mysqldump -u root xyz > backup_$(date +%Y%m%d).sqlworks because it generates the file if I run it at the command line.Any helpgreatlyappreciated!
Running MySQLdump for XAMPP in CentOS
If you're host doesn't allow wget. Write this simple php script:script.php:<?php $homepage = file_get_contents('http://www.example.com/?param=2&param2=sdf'); echo $homepage; ?>Then just put script.php in your cron.I'm not entirely sure what your cron needs to do, does it need to return anything? If it just has to call it, and you don't need any dynamic parameters, this would be fine.
This question already has answers here:Closed11 years ago.Possible Duplicate:Cron Jobs calling a PHP script with variablesI have a cron job set up and my command looks like this:php -q home/seatbe5/public_html/shop/index.php?page=sendorder/sendorderI get an error saying no input file specified?When I remove the route=... it works fine. is there a work around to this?Thanks Peter
Can I use GET with CRON in PHP [duplicate]
I'll tell you what worked for us. First of all, we checked that cURL is installed. It wasn't so we installed it. Then we followed the following steps:http://shaun.net/2011/09/solving-plesk-10-3-1-cron-issues/To fix the problem and restore behaviour to how it worked in previous versions of Plesk, all you need to do is run the following command: /usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"But you have to find the correct route of your file "server_pref". Following these steps, we are able to use the cron with curl -qhttp://youradress.com/cron.phpHope it helps, best regards
Hi i have tried to run the php file in the plesk by using cronjob by the following commands.But everything is showing the errors. Not executing the php script.i.e.,php -q /path to the fileshows php command not found.so i have tried to find the path for php by usingwhich phpit displays the path /usr/bin/php. after that i have tried with/usr/bin/php -q /path to the fileit shows/usr/bin/phpno such file or directoryThe same way i tried for/usr/bin/env /usr/bin/php -q /path to the file /usr/bin/curl /url of the file /usr/bin/wget /url of the fileevery thing is showing the error and not executing the script. what is wrong with this. Can any one suggest me. thanks in advance
Crontab is not working in plesk after changing the path too
It means, Fire every 10 seconds.For 10th second of every minute, use "10 * * * * *" expression. It fires once a minute where as " */10 * * * * *" fires 6 times a minute.
Java spring scheduler quartzI have old code with expressschedule="*/10 * * * * *"i do not understand what does that mean ?Even after readying the following file can't figure out what does above Cron expression do.http://quartz-scheduler.org/api/2.0.0/org/quartz/CronTrigger.html
Spring quartz schedule expression
Check out thewhenever gem. It's a wonderful gem to abstract all the nastiness of cron. Just include the command as you have written above and it should be fine.
I have a gem that packages one .rb file containing my class and associated methods as well as a corresponding .bin file.Locally, I can run everything just fine like so:command_to_bin input_file output_fileI don't want to run this manually every day so I'm considering using cron on a server, but I'm a little unsure how to proceed.Do I throw everything into a directory (.gem file, input file, output file) and just point the above cron command at the directory?I've looked atthisand sort of understand what's going on. I guess what confuses me the most is that when I look at all the web hosting providers, they mention domains and applications, but I just want to know how to have the standalone script run by itself without it being built into a web application or associated with a domain.
What's the simplest way to run a cron job on a standalone Ruby gem?
You have a couple of options, but essentially, you have to start using SSH key authentication instead of username/password authentication.The options depend on what, precisely, you'd like to identify using the key. For your case I'd say it's either Deploy Key (which is bound to a machine) or a Machine User (which is bound to a specific user account, possibly across machines).See this GitHub article for the details:https://help.github.com/articles/managing-deploy-keys
I'm about to wrap up a project with a client. I'm using github to store all of the files. He is naturally going to be making updates via the CMS, uploading new images, etc after I am off the project.I am afraid that six months or a year from now if something breaks we will be in a bad place because it will be a full year or so of changes without any git commits (Again, this is a client. I don't expect him to SSH in and run git commands.) I'm trying to set up a crontab job that will run hourly that will add everything, commit it, and push it to github. The problem I am running into is that it asks for my username and password and fails. How can I set it up so that my client's server can push changes to the github repo without having to compromise my security?Here is what I have so far.0 * * * * cd ~/clientswebsite.com/; git add -u; git commit -m "Cron job"; git push --verbose > log.txt
How do I set up auto git push every 10 minutes from my client's server?
You need to specify a full path or change current directory before running script. The script has no access rights to create a log file in the directory where cron starts it.
I'm using crontab to execute my script every minute. But script don't work properly. This script should create file, log to another file and write to DB. Only write to DB work. When I start script manually it work fine. This is script:#!/usr/bin/php <?php require 'include/functions.php'; require 'include/logger.php'; $lock_file_name = "test.txt"; $lock_file = fopen($lock_file_name, "w+"); fclose($lock_file); $log_file = "test.log"; $log = new log($log_file); $logEnabled = 1; if ($logEnabled==1) {$log->add("DEBUG: Start test.");} if_dbconn(); $SQL = "INSERT INTO .`test` VALUES (1666, 6, 6, '6', '6', '6', '6', 6, '6', '6', 6, 6, 6, '6')"; mysql_db_query($db,$SQL); ?>My cron look like this:* * * * * /usr/bin/php -f /path/to/script/testCron.php > /dev/null
Crontab doesn't log to file
Not sure what that specific UI interface allows...but if you can multi-select (hold down "ctrl" and click other minutes)...then just select 0,10,20,30,40,50If you have access to actually edit the REAL crontab commands...the format is like this:0,10,20,30,40,50 * * * * /path/to/commandOr...to simplify this, the "better" way is like so:*/10 * * * * /path/to/command
Setting up cron is confusing, although I managed to set it to run every hour, but I can't quite figure how to change to run every 10 mins. This is the UI in admin panel:
Cron time setup
You will need to make sure that, when the script is ran fromcron, it has the proper working folder set, so it can loadmail.php. Using thegetcwd()andchdir()functions are the two you need to use.Usually, when ran from web browser (on an Apache server), the working directory is/var/www, but fromcron, it is usually the root of the filesystem,/.
I have a php script that is going to be a cron job and it was working fine until I added the email script I have been using.I have used the email script all over the site before but when I try and run the cron job using it from the command line it fails.The mail script looks as followed<?php require_once "Mail.php"; function sendMail($to, $from, $subject, $message) { $no_errors = true; $host = "ssl://smtp.server.com"; $port = "465"; $username1 = "username"; $password = "password"; $headers = array ('From' => '[email protected]', 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username1, 'password' => $password)); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) { $no_errors = false; echo $mail->getMessage(); } else { $no_errors = true; } return $no_errors; } ?>If I comment out the include send_mail.php it works fine but doesn't send email.Any ideas?
Cannot use Mail.php from command line
Make sure you don't have hashes (comments) at the start of your crontab commands.Additionally:Crontab commands should be run in isolation.Each crontab command will be run in its own context, changing directory in one instruction probably won't lead to that directory being sound for the next executed (they may be run in their own environments, e.g.).To overcome this, write a simple shell script which encompasses all of your commands for a single action.# MyCommand.sh cd /home/sam ./code/imageUpdate > image1.txt # crontab command 50 17 * * * /home/sam/MyCommand.sh
I am using ubuntu 12.04.I am using a script(./home/sam/code/imageUpdate) tosynchronising imagesfrom server to a particular folder in local system. And I have to run the script in the evening always. So I want to write acrontabwhich will automatically runs the script.My commands :$crontab -e;And added the scheduled time to thecrontabfile.# 50 17 * * * cd /home/sam # 52 17 * * * ./code/imageUpdate > image1.txtThen I saved the file and waited for the result.But I didn't get any result. No image was been synchronised to image1.txt file.Have I left any step ?Please help me out... Thanks in advance.
CRON : Scheduling task
You can simply add a shebang line to your PHP script and make it executable (chmod +x):#!/usr/bin/php <?php // your codeThen you can use it in the crontab like any other script/program, i.e./path/to/whatever.php.
I have a database where uploaded music details are stored.In my database I havelocationof music storedData of Table is like this:TableA id musicpath status 1 /X/Y/Z/abc.mp3 1 2 /X/Y/Z/abc1.mp3 0 3 /X/Y/Z/abc3.p3 1 4 /X/Y/Z/abc5mp3 1In the above table, id isauto-increment, andmusicpathis the location where music is stored. If the status of any row is 1, cron will run and compress the uploaded music and replace the existing file and the status will be updated to 0. I have ffmpeg installed and I can compress using ssh but through PHP I tried but its not working so i have decided to writeCRONcron will execute this code for compressing but other details if any one can share it wil be a great help.exec('ffmpeg -y -i ' . $_FILES['song']['name'] . ' -ab 24000 ' . $_FILES['song']['name'] . '');i know how to setup cron to execute the php file . but i dont know how to write php file which will be executed by cron.
How to write a PHP code to execute a CRON job?
This is the key:sh: 2012-06-08-01-25.sql.gz: Permission deniedChown/chgrp to a user/group with write permissions and/or modify permissions with chmod so the executing user/group can read/write to the destination directory.The pipe is broken because it cannot write the file, permission denied.
I know that what I'm doing wrong is not including the right, full file path information but after hours of tweeking I'm still getting ash: 2012-06-08-01-25.sql.gz: Permission denied mysqldump: Got errno 32 on writeerror. Here's my script:$dbhost = "DATABASE HOST"; $dbuser = "DATABSE USER"; $dbpass = 'PASSWORD'; $dbname = "DATABASE NAME"; $backupfile = '/home/12345/data/backup/'.date("Y-m-dTH:i") . '.sql.gz'; system("mysqldump -h $dbhost -u $dbuser --password='$dbpass' $dbname | gzip > $backupfile"); $backupfile = $backupfile; # To S3 require('/home/12345/data/backup/S3.php'); if (!defined('awsAccessKey')) define('awsAccessKey', 'ACCESS KEY'); if (!defined('awsSecretKey')) define('awsSecretKey', 'SECRET KEY'); $s3 = new S3(awsAccessKey, awsSecretKey); if (!$s3->putObjectFile($backupfile, "BUCKET", 'db-backup/'.$backupfile, S3::ACL_PRIVATE)) { die("104"); } system("rm $backupfile");The script is zipping my database using gzip and mysqldump, and then uploading this ZIP to a secure, encrypted folder on an S3 bucket.
Cron job full path: Still getting broken pipe errors
Can you run it from the command line?nohup php -f /path/to/x.php &Withnohupit'll keep running even if the user logs out.The cron solutions in other answers will start a new instance each time they are run - not sure if you want that. However if the script dies and you want to restart it, then you will have to run a separate daemon that checks if it's running and if not, start it. You could make a simple script that does the check and starts running it, and then cron that script to run say every 5 minutes or however often you want.
I have a php loop that I want to constantly run. Currently if you leave x.php running in your browser then it loops forever. as long as you have the browser window open... and it works great.How do I get it to run constantly without me having to sit with a browser tab open on it? I want it to run 24/7 and if it ever stops running. it needs to restart itself.Thanks
Constantly run php loop without leaving browser open
Cron doesn't have a retry feature which taskqueue has, so I'd recommend using frontend cron in order to put a task onto a Task Queue with a dynamic backend instance. That way, cron request itself will be handled by a vacant frontend instance, which is more reliable than what you're doing now, and your backend task execution will be retried when in failure.For making the first cron call robuster, you can make the cron request several times for one particular backend task, and upon putting a task, name a task something associated to a particular task(e.g. 20120430-task1 or something), catch errors for task duplication(and do nothing in the catch clause except for logging).For more details about named task, please see:https://developers.google.com/appengine/docs/java/taskqueue/overview#Task_Names
We have two cron jobs that hit two different dynamic backends and both are having the same problem. I'm able to duplicate the issue by navigating to the URLs that the cron jobs execute directly in the browser.Our app has a fairly high cold start time. When I navigate to the URL that uses backends, I see the following errorError: Server Error The service you requested is not available yet. Please try again in 30 seconds.In the logs, I see the request to /_ah/start (we don't have a specific handler for this) for the backend with this message:This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.Then what I did was refresh the backend URL and it worked fine.So my theory is that the cron job would work fine if the backend was already loaded. If it's not, it doesn't wait long enough to see if the backend will load up.Assuming that's correct, is there a way to have the cron job wait until /_ah/start has finished?Two other options are to use a resident instance which we'd rather not do, or to improve our cold startup time which is on the todo list but hasn't been an issue for us until now (we use a resident instance for the frontend).The backend is a B1. Suppose we could upgrade this but again, being a cash-strapped startup, I'd rather not.
AppEngine backends returning 503 - Java
$fileHandle = "latest.html", 'w');I'm going to assume you mean$fileHandle = fopen("latest.html", 'w');the 'w' here opens the file, places the cursor at the start and truncates the file to zero length.If you check count($links) before doing this you wont truncate the file when there is nothing to be written to it.<?php $links = "QUERY HERE AND HANDLE THE RESULTS (REMOVED)"; if (count($links) > 0) { $fileHandle = fopen("latest.html", 'w'); fwrite($fileHandle, implode(" • ", $links)); fclose($fileHandle); } else { echo "Didn't work!"; } ?>
I have this issue where cron runs a php script every 5 minutes to update a list.However, the list fails to update 5% of the time, and the list ends up blank. I don't believe it's related to cron, because I think I failed to manually generate the list twice out of like 100 tries.What I believe it's related to is when the site has like 50+ people on it, it will fail to generate, perhaps being related to the server being busy. I added a check to make sure it's not MySQL not returning rows (which seems impossible) but it still does it leads me to believe fwrite is failing.<? $fileHandle = fopen("latest.html", 'w'); $links = array(); $query1 = $db_conn -> query("SELECT * FROM `views` ORDER BY `date` DESC LIMIT 0,20"); while ($result1 = $db_conn -> fetch_row($query1)) { $result2 = $db_conn -> fetch_query("SELECT * FROM `title` WHERE `id` = '" . $result1['id'] . "'"); array_push($links, "<a href='/title/" . $result2['title'] . "'>" . $result2['title'] . "</a>"); } if (count($links) > 0) fwrite($fileHandle, implode(" • ", $links)); else echo "Didn't work!"; fclose($fileHandle); ?>Could there be a slight chance the file is in use so it ends up not working and writing a blank list?
Fwrite Fails w/ PHP Cron
Just make the script run continuously with a random delay between actions. Put it in cron as @reboot and it will restart when the system does.
I defined a cronjob with thewhenevergem for Ruby. This created a cron job for the user that runs a ruby script every 5 minutes. The user is not root and doesn't have root permissions.I would like to be able to run this job randomly between 3-6 minutes. I'm running this job on CentOS 6.2
Is it possible to run a cron job randomly between 3-6 minutes?
Your issue is configuring the startTime. startTime is meant to be the time at at which the trigger should occur. Since the date is old this causes a misfire in the scheduler and the default behavior is for the scheduler to immediately refire.Remove setStartTime, the default behavior is for startTime to be set to the current time and the first trigger time will be the match to the cron trigger after the start time so this Thursday.Quick little test I through together to verify:public class Test { public static void main(String[] args) throws ParseException, SchedulerException { String groupName = "group"; String cronExpression = "0 13 13 ? * THUR"; CronTrigger cronTrigger = new CronTrigger("trigger_" + groupName, groupName, cronExpression); cronTrigger.setStartTime(new Date(0)); Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); JobDetail detail = new JobDetail("testJob", groupName, TestJob.class); scheduler.scheduleJob(detail, cronTrigger); scheduler.start(); try { Thread.sleep(50001); } catch (Exception ignore) { } } public static class TestJob implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { System.out.println("TEST"); } } }When removing the setStartTime my print message does not trigger. With it there the print message triggers.
I am using following cron expression to execute a job on every Friday at specified time of day (in sample below it's 1:13 PM).0 13 13 ? * FRISo expected behaviour should be if I initialize this trigger any day other then Friday then it should not start executing until next Friday. But whats happening in my case is even if I initialized this trigger today (as today is Wednesday), it starts executing jobs at the very moment.Relevant java source:CronTrigger cronTrigger = new CronTrigger("trigger_" + groupName, groupName, cronExpression); cronTrigger.setStartTime(startDate); //startDate = 1-Mar-2012 cronTrigger.setEndTime(endDate); //endDate = 30-Apr-2012
Quartz CronTrigger executing jobs on wrong date/time
Given that the format of cron is MIN HOUR DAYOFMONTH MONTH DAYOFWEEK, this should work.30 0 5,7,10 * * script.sh
How to setup a crontab that starts on: 5, 7 and 10 of the month at 00:30? Tnx
How to setup a crontab that runs in some separate days?
You can create a PHP script that is accessed via GET and does the two POST requests itself.You can simulate the POST request on both the login page and the import page by usingPHP CURL.StepsSend a POST request with CURL to the login page. You specify to CURL to keep your cookies (cookie jar,read the manualfor the exact syntax).After the session cookie is saved in the cookie jar (a file),send another post to your import page, using the authentication received from the first POST.You can find more information about the CURL POST here:http://www.electrictoolbox.com/php-curl-form-post/
Using cPanel I want to setup a cronjob. I have a php page doing the import with post data. But to reach that import page I have to pass a login page also working with post data.Can it be done?
cronjob running php web application
You probably need to pass-stocurlif you're running it via the command line, to tell it to be silent and not output progress information to the terminal.Pass-Sas well (e.g.curl -s -S) to make it show error messages if it encounters them, even though you've otherwise silenced it.
I am receiving the following in my email every time the cron job is running:What does it mean? Is something wrong? Why am I receiving this message?% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 6 0 6 0 0 22 0 --:--:-- --:--:-- --:--:-- 22 0 6 0 6 0 0 22 0 --:--:-- --:--:-- --:--:-- 0
Curl shell php cron results
It is probably under a different user. Check root usersudo crontab -e. Each user has it's own crontab and there's one for the whole system. Note: Through the crontab configuration you can disable per-user crontabs.
I had a cronjob set up to run a php script daily, which went well for about a month. Today, I realized it didn't run the script so I opened up the crontab. The crontab is completely empty - what happened?I don't know too much about cronjobs, but as far as I understand, they do not delete themselves if the server is reset. How can I make sure cronjobs are always running and that it doesnt get deleted?
Cronjob on Amazon EC2 Deleted?
Just run awgetcommand to make a request to the page, using a cronjob.
I have created a php file I want to run every day at 8am on my linux webserver. The page is accessible online, but I want to schedule a cronjob to basically mimic a request to the page every day at 8am. Is this possible? if so, how?
Run a webpage from Shell
: change your script to use command line parameters instead of_GET: the first argument is in$argv[1]variable2: create cronjob like this:*/5 * * * * /usr/bin/php /path/to/script/index.php dltnote, that you may have to specify full path tophpbinary (whereis php) and to your script.3: if there's someincludeorrequire- change path to absolute.
I have read the answerhttps://stackoverflow.com/questions/1830208/php-cron-job-every-10-minutes#=I have similar kind of question: I am trying to run a cron job to execute a php function which will delete some fields , after checking some conditions . So I want to know how will I run the function within that php file . Should I add the path like 'http://somename/index.php?do=dlt" or just the function something else
Run cron job to execute a php function after some fixed time
http://www.mywebcron.comseems the best. Has no interval limitations.
I don't have access to the PHP bundle, I just want to register somewhere my script, than run it every hour. Any possibility?
Online service that loads my PHP script repeatedly?
I do not know about tomcat, but on Windows the way you schedule jobs is using the "at" command at the command prompt.There is also another way, if you go to Start/Programs/Accessories/System Tools/Scheduled Tasks. (May vary depending on which version of Windows you have.)
I need to run a job in a scheduled manner, on tomcat server deployed on my local machine having windows OS .
Scheduling a cron job in localhost windows
I think what you want is something along the lines of a reference count: if you put this in .bashrc( counter=$(cat ~/.login_count); echo $(( $counter + 1 )) > ~/.login_count )and something like this in .bash_logout( counter=$(cat ~/.login_count); echo $(( $counter - 1 )) > ~/.login_count )Then~/.login_countwill contain the number of active terminal sessions, assuming you always log out cleanly.You can then test that this is non-zero in your cronjob to see if at least one terminal is logged in:0 * * * * [ $(cat ~/tmp/counter) > 0 ] && do_backup
I am trying to setupcronin aUnixenvironment to sync my code and config files to a backup folder every hour.I need this to happen whenever I'm logged into my work terminal and at an hourly frequency. So, I inserted the following into my .bashrc file:0 * * * * rsync -avz ~/codes/ /cheap/code_bkpHowever, now when I'm logged into multiple work terminals, each of them run the job independently and I get multiple emails(1 for each terminal) every hour.I would like to ensureonly 1 terminalruns the cron job. Kindly suggest some way of doing so and avoiding the multiple terminal issue.
Avoiding multiple cron jobs when logged into multiple terminals
After further researching I was able to determine that there are two modes to php running: cgi or cli. Upon testing withphp -vin shell I confirmed it was configured for cli, but running the same with a Cron job I saw the result being php running as cgi.To resolve this I reconfigured my Cron job as follows:/usr/local/bin/php /home/overstoc/www/admin/index.php cron updateI assume the default php that the Cron job is calling has a configuration for cgi where the server share is cli.
I am running a new site on Codeigniter 2.1.0 and have configured the following Cron job:php -q /home/overstoc/www/admin/index.php cron updateThe output sent to me shows that only the default controller and default action are being called. Any parameters being sent are ignored.Any suggestions on the way to debug this or a known bug that causes this problem?Logging onto the server I am able to successfully load the desired controllers and action manually through SSH. However, the Cron job is not passing the requested parameters.
How can I debug a Codeigniter Cron job that only runs the default controller and action when called?
Executinggotit.phpis easy. You just use curl or (if allowed) file_get_contents to download the image src. For the JavaScript, you need to figure out what network requests that causes, then do them manually.EDIT: If gotit needs to keep outputting that image, then you can have page.php parse the HTML, then do its own request to the resulting src (which will be website.com/sale.php...).
Server 1 Pings/Request URLhttp://website.com/page.php?code=NeedThatServer 2 "page.php" grabs "NeedThat" and execute img src or JavaScript on server sideImage Code on page.phpThanks a lot forr the help got it!
Can php run code on server side without user request?
*/5 * * * * blctrl /home/blctrl/code/perl/tt01.plThat looks like the syntax for/etc/crontab, the system-wide crontab file. The first 5 words indicate when to run the command, the 6th is the account under which to run it, and the rest of the line is the command to execute.(The clue was that the command is under/home/blctrl, which would be the home directory for the accountblctrl.)The syntax for your own crontab, the one you feed to thecrontabcommand, is different. You don't specify an account name, because it only runs under your own account.Try this:*/5 * * * * /home/blctrl/code/perl/tt01.plEDIT: Incidentally, the first thing I would have tried when encountering a problem like this would be to replace the command with something simple, perhapstouch /tmp/FOO. That would have told you whether the problem was with your Perl script or with your crontab.
I maintained a database (MySQL), I would like back up some data to the database using a perl script. To save my trouble, I would like cron to do it for me, I inserted the following using crontab*/5 * * * * blctrl /home/blctrl/code/perl/tt01.plHowever, cron never does its job, any suggestions to get it done? The Linux installed is Centos 5?
Perl script executed by Cron failed
Assuming you have thefopen HTTP wrapperenabled...$fp = fopen( 'http://somedomain.com/index.php?option=csome_option&view=some_view&key=some_key&format=some_format', 'rb'); if ($fp !== false) { fclose($fp); }
I would like to know if, and how, I can call or execute what otherwise would be known as a cron jobIf I were to enter this crontab through my host cron manager interface it would look like:wget "http://somedomain.com/index.php?option=csome_option&view=some_view&key=some_key&format=some_format"Is it possible to run this http call everytime a page is loaded (using PHP)?I do not want to display the outcome of this call, but rather simply execute what this call would get going if I were to call directly through a browser, but (inevitably sounding redundant) without displaying simply executing behind the curtains on cue from page load.Thank you,
execute http (otherwise know cron job) whenver page is loaded (php)
some linux servers use different syntax. To run a job every minute there is 3 ways.* * * * * /usr/bin/php -f /var/www/vhosts/process/sync.php > /var/www/vhosts/process/logs/synclog.log 2>&1 */1 * * * * /usr/bin/php -f /var/www/vhosts/process/sync.php > /var/www/vhosts/process/logs/synclog.log 2>&1 1 * * * * /usr/bin/php -f /var/www/vhosts/process/sync.php > /var/www/vhosts/process/logs/synclog.log 2>&1Depending on server and setup one of these should work. Since you already stated the first does not, try one of the other two. I know my hosting server, I cannot use */1.
I have a cronjob, which is ni-on identical to other cronjobs that do work. But, for some I see nothing from this:-* * * * * /usr/bin/php -f /var/www/vhosts/process/sync.php > /var/www/vhosts/process/logs/synclog.log 2>&1I want to run every minute, of every day, forever. However, this script isn't be actioned. I know this as I can run it from CLi and it works, as well as outputting a file.Is there something wrong in the command? If not, is there a way to monitor this command so I can see the issues?I've also checked the permissions, and they're identical to the other files that do work.Many thanks for any help.
Another of the:- Cronjob not working
I think the best you could do is make a cron job that periodically checks a file X for cron jobs and runs them. Then all you would have to do is add jobs to X instead of to cron.
How can you do a cron job with php without creating a cron Job on the server cron softwareIs that even possible ?EDIT as I added in a comment I've seen a script called piwik who does that kind of stuff, e.g. Sends emails without any cron job
Cron job with php
The problem is solved. I made a file reference in the root template in which the PAGE object was configured, like this<INCLUDE_TYPOSCRIPT: source="FILE: fileadmin/typoscript/template-setup_main.ts">After configuring the object directly in the setup of the template no more error messages appeared and now I am a lucky guy ;)@Koopa: Thanks for the hint!
I have a problem with my scheduler in TYPO3 4.5.5. Every time a task is executed it fails with the following error message:[scheduler]: Task failed to execute successfully. Class: tx_jobportal_apply, UID: 5. The page is not configured! [type= 0][]There are 3 domains in my page tree, each having an own root template. The TypoScript Object Browser shows a setup with page.typeNum = 0
TYPO3 Scheduler: The page is not configured! [type= 0][]
If you want to run every hour, don't bother checking. Heroku will run it hourly.Since %1 will always return 0, better to just have:desc "Tasks called by the Heroku cron add-on" task :cron => :environment do puts "Updating view counts...." Video.update_view_counts puts "Finished....." #... if Time.now.hour == 1 #1am #... end endAlso, if you want to be able to run Video.update_view_counts when you need to, you could instead (after creating the rake task):Rake::Task["video:update_view_counts"].invokeThat way you can run it inside of cron, and manually if needed
I just acquired the paid version of Heroku's cron, in order to run some tasks every hour. What I would like to know is the syntax I should use to actually get it to run every hour. So far I have this, Could you please tell me if it's correct:desc "Tasks called by the Heroku cron add-on" task :cron => :environment do if Time.now.hour % 1 == 0 # run every sixty minutes? puts "Updating view counts...." Video.update_view_counts puts "Finished....." puts "Updating video scores...." VideoPost.update_score_caches puts "Finished....." puts "Erasing videos....." Video.erase_videos! puts "Finished....." end if Time.now.hour == 0 # run at midnight end endI need to know if this line with the1in it is the way to go...if Time.now.hour % 1 == 0Thanks in advance for your help,Best Regards.
What's the syntax to run a cron job on heroku every hour?
CURL and WGET are more adecuate for URLs likehttp://myhost.com/cron.phpWhen the script is offline, you would better run it using php CLI:Ex:php -q cron.php
I want to run a PHP script every 15 minutes using either CURL or WGET.This PHP file is in a local folder:/home/x/cron.phpHow would I run this using CURL/WGET?It doesn't work when I try to runcurl /home/x/cron.phpThank you!
Cronjob using CURL/WGET
WHERE registration_date < CURRENT_TIMESTAMP - INTERVAL 72 HOUR AND registration_confirmed IS NULL
I have a database that has a users table. Within the table are two fields: a datetime field for when users initially register with a website, and another datetime field for when that registration has been confirmed by the user via e-mail.I'm expecting a lot of people to register but never activate their accounts, and I don't want to bog down my table with non-users, so I am creating a CRON script. The script will run every 24 hours, and will delete the rows where the user has registered but hasn't activated account after x number of days. the pseudo-code would look something like this:DELETE FROM users WHERE [registration_date is more than 72 hours after NOW() ] AND ISNULL(registration_confirmed)As I said that's the pseudo-code; I am not sure how to get the time gap between a datetime field and NOW(). Any help would be greatly appreciated.
Getting time gap between a datetime field and NOW() in MySQL
As you can see, there are 2 request instead of one when using HTTP requests. All modern browsers attempt to retrieve the favicon.ico file from the server, and, even if it does not exist, it is counted in the graph.
I wrote a program to send mails from GAE. It can be run in two ways:-as a http requestas a scheduled cron job (by writing job desc. in cron.yaml)Requests per second for the latter case is almost half the former.Why could be the possible reason for this?
Requests per second comparision in http versus cron job on GAE
You didn't wrap the`command`string in double quotes, so if the string isn't found, the command reduces toif [ -z ]which is an error (missing parameter). (It expands tonothing, not to an empty parameter.) And it's doing things the hard way.if grep ">Success<" $OUTFILEYou may want the-sand (if GNUgrep)-qoptions ongrep.
I have a unix script that occasionally errors out with the message "test: argument expected". The following line of code is the only if statement in the scriptif [ -z `grep ">Success<" $OUTFILE` ]The $OUTFILE is a file created when the script starts to run. The script calls a web service that writes the output to the OUTFILE. If the outfile has "Success" in it, then it means that the web service completed successfully.This script is called every 10 minutes and the logic above works perfectly fine for most of the cases. But on occasionally, the script errors out with the test argument expected error and I am unable to figure out the reason for this error. Has anyone else faced a similar problem? It would be great if someone can provide pointers to this issue.Thanks.
test: argument expected when using -z option
The JVM already does that for you:public static int main(String args[]) {...In args[] you will have the command line arguments.If you want more sofistication (as named parameters, v.g. -title = MyTitle), you can try Apache Command Line Interface(CLI) library.EDIT to answer featon's comment: That will not work, the OS will interpret it as a call to launch a new process. Also, the process name of all java processes is "java" (the OS runs the JVM and does not know what it does in inside).If what you want is to communicate with a Java process already running, you must open a communication path. Two alternatives are:Open a TCP port, launch another application (Java or not) that sends the message there.Have the process periodically listing a directory, if any new file appears wait a while (so it is fully created), open it, read it and delete it.Another path is getting to use J2EE application server that implement functionalities more oriented to Java process that run continuously (even equivalents to cron tasks), but they take some effort to become familiar with.
Is there an easy way of passing Linux/Unix commands to Java'sargs[]during program execution? I would like to use Java app with cron.
Reading from command line during execution
I would like to have everyone know who is looking to make their own cron from wordpress to look here.http://wpdailybits.com/blog/replace-wordpress-cron-with-real-cron-job/74I appreciate everyones help but this is a great overview I've found.
I am writing a wordpress part of my site with php and am working on writing a cron that works within my wordpress site. I don't want to use wordpress cron cause it only executes when people come to your page so I would like to use cpanel cron but be able to reference a cached object in wordpress but I haven't used cpanel cron and don't know how to reference it completely with php. Can I make a cpanel cron job in php and have it run it hourly and cache the variable to be used by wordpress without wordpress running it everytime I load it when including the file in wordpress? Do I have to include all files in php to have the variable of use or does global variable in php is accessable in all php files? I'm kinda a newb when it comes to using cpanel, php, and wordpress. I know this is a lot to ask but I am greatly appreciate it.
Wordpress Cron Function using Cpanel
A more robust method would be to accept command-line arguments in your PHP script withgetopt()or$argvand making it executable. An example with$argvcalledscript.php:#!/usr/bin/php <?php if (isset($argv[1])): echo $argv[1]; endif; ?>Make it executable:chmod +x script.phpAnd execute:./script.php "cron/24satahr"Will output:cron/24satahr
I have a cron job set likephp /home/novinarb/public_html/index.php --uri="cron/24satahr"but the 'uri' param doesn't get to the php script at all. I also tried without the -- in front of uri but still nothing. Any ideas?
Cron not passing params to PHP script
Yep. If you can, do use them. There would be other solutions, like having the first user hitting your site after xx hours run those same scripts but the solutions would be cumbersome and less-than-ideal.Cron is the way to go.
there is a facebook app which I'm writing , Users grant offline_access to the program . I need to collect information about them for example twice a day at 12 am and pm .how should I do this in PHP? should I use cron jobs in linux/windows or what?
scheduling job in php
cron runs scripts with a very minimal environment. In particular, its PATH doesn't contain all of the usual binaries directories, just /usr/bin and /bin, so any commands in other binaries directories (like wget) will not be available.There are several ways to fix this. One option is to have your script give the complete path of wget:#!/bin/sh /usr/local/bin/wget -r -l3 --no-parent -nc -A ".shtml" 'http://some.url/somethingelse/'(or whatever its actual path is -- usewhich wgetto find out.)Another is to explicitly set PATH in the script:#!/bin/sh PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin wget -r -l3 --no-parent -nc -A ".shtml" 'http://some.url/somethingelse/'(or whatever PATH you normally use; be sure it includes wget's location.)Or you can set the PATH in your crontab:PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin 00 16 * * * /Users/myusername/script.sh 04 16 * * * /Users/myusername/crontest.sh
I am completely baffled by the behaviour of cron under Mac OS 10.6 Server. I am trying to run two scripts in a cronjob like this:00 16 * * * /Users/myusername/script.sh 04 16 * * * /Users/myusername/crontest.shWhile 'script.sh' contains a wget command:#!/bin/sh wget -r -l3 --no-parent -nc -A ".shtml" 'http://some.url/somethingelse/''crontest.sh' contains just a test script:echo "hi" >> /Users/myusername/crontest.txtProblem is, 'script.sh' does not fire, but 'crontest.sh' does. What could be the cause of the wget script not firing? Do the scripts require a specific encoding? Does cron write a log file somewhere?(I tested the wget command by itself in the shell, where it works fine.)
mac os 10.6 server: crontab does not fire wget script
When you are at the command prompt, you can use:crontab -l // list crontab entries crontab -e // edit crontab entries crontab -r // remove all crontab entriesAll of the current user of course (can be root).
How to stop the CRON's set using SSH access. These CRON's are not displayed in my control panel as they are set using SSH access. I do have a ROOT access as its a virtual server.Please help me.Regards Gourav.
How to stop the CRON's set using SSH access
Cron won't run from the same directory as your php file is in, so you'll need to change to it first:cd /home/user/public_html/cron_jobs/ && /pathtophp/php -f file.phpI recommend the full path versus~when dealing with cron scripts to avoid confusion
I've spent days still can't figure out this.I have following file structure under public_html:cron_jobs/file.php contains - > include('../base/basefile.php') base/basefile.php contains - > include('baseSubFile.php')when I run/pathtophp/php -f ~/public_html/cron_jobs/file.phpit works ok but when I copy the same command to cron in cpanel, I get error saying'basesubfile.php' can't be foundPlease help.
php path, cron and cpanel
In the log4j extras projectlog4j extras projectthere are many useful appenders that can be used. In particular the with theRollingFileAppenderconfigured with theTimeBasedRollingPolicycan automatically compress the rolled file. I don't know if theSizeBasedTriggeringPolicydoes the same, and the documentation is scarse.I think that it would be easy to build a custom RollingPolicy that is SizeBased and compress the output, given that all the ingredients are present in the Log4j extras project (even the compression of the file). It is basically the same code as the TimeBased policy, implementing theisTriggeringEventmethod to be the same as the SizeBased policy.Or something like that.
What I want is this: Just like Glassfish 3 server log, if the log file pass certain file size(like 2MB), the log file will automatically zip itself, so that the log file will not become too large. I am not sure if this is done vialogapi orcronapi. Is it possible to obtain what I describe above usinglog4jor is there some type ofcronprocess involve here? Here is my property file for log4jlog4j.rootLogger=DEBUG, LOG , stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO log4j.appender.LOG=org.apache.log4j.RollingFileAppender log4j.appender.LOG.File=C:\\dev\\harry\\data\\logs\\core.log log4j.appender.LOG.layout=org.apache.log4j.PatternLayout log4j.appender.LOG.Append=true log4j.appender.LOG.layout.ConversionPattern=%5p %d{d/MM/yy HH:mm:ss}:%m%n # log4j.appender.LOG.Threshold=INFO
Can log4j compress a log file after file size pass 2MB
this command just downloads the web page "http://www.ynhwebdev.de/newsletter/mails/sendAll" which I assume is doing something on the server side (e.g. send some mails?) and sends the result to root (or whoever gets the cron mail)If you list your cronjobs withcrontab -lit should show 5 colums like0 5 * * * wget....which means it is executed at 05:00 every day.
I recently study a newsletter system, there is a Cronjobs like this, I really do not contact linux Cronjobs before, anyone can explain it for me? Thank you very much.wget -O - -q -t 1 http://www.ynhwebdev.de/newsletter/mails/sendAll
What is this CronJobs means?
I thinkwhoshould do the trick. It will show you a list of all the users that are logged in to the system at a time. You can write this to a file and then have it mailed to you.wwould get you what the people logged in are currently doing.So, the script would look like:#!/bin/sh HOME=<your home directory> who > ${HOME}/usersLoggedIn.txt w > ${HOME}/whatLoggedInUsersAreDoing.txt${HOME}refers to your home directory. On the command prompt,echo $HOMEshould give you your home directory. The output of the commandwhoandwwill get redirected to the filesusersLoggedIn.txtandwhattLoggedInUsersAreDoing.txtwithin your home directory. You can, of course, change the directory and file names to which you want this data to be written.HTH,Sriram
I am in a UNIX system administration course at school and have to generate a Cron job that does the following:Queries the system each hour to find out who is logged in.Mails the result to my email account.I know that the actual crontab will look like the following:# Check to see who is logged in every hour. MAILTO="[email protected]" 0 * * * * root /tmp/loggedin.shOR# Check to see who is logged in every hour. MAILTO="[email protected]" @hourly /tmp/loggedin.shBut I have been Googling for some time and have been unable to find any examples of what exactly the .sh file should look like. I know it starts with:#!/bin/bash # Shell script to see who is logged in, to be run every hour.And I have no idea what else to put in there. Any help is greatly appreciated!
Crontab Script File Syntax
The Subversion repository contains a single unique Revision number which is for the whole repository which is implicit a Tag. So the simplest solution is to use this revision number instead extra tagging step.
I want to automatically tag the daily SVN repository at 6:00 pm so that the daily code snapshot can be maintained and I could at anytime in the future go back to any earlier code repository snapshot. We we do this with a script that runs through a daily cron job ?
automatic daily tagging of the SVN repository
The best route to achieve what you want ("cron job creates data for use by javascript") is to go via JSON. This involves:Create a cron job that a) fetches the data, and b) writes it to a file formatted using JSON conventions which is accessible from your web server,Amend your html to include the file created by the cron job.For simplicity you could create the javascript file using contents similar to the following:var agentValues = [ "excel", "msword", "ppt", ];You can easily create this with a static first and last line, and simply add the quoted values from your query in between. You can then load this file into your html document like any other javascript:<script type="text/javascript" src="..."></script>When you populate the autocomplete values, simply use aforloop over this array:for (var i = 0; i < agentValues.length; i++) { $("<option>" + agentValues[i] + "</option>").appendTo($values); }The above would be the most basic version of achieving your aims, and you can improve on it, e.g. by:Adding error checkingStructuring your namespace so that you don't have many top-level variablesAdding the data values to your existing javascript, rather than a separate fileetc.
It's probably easiest to understand by looking at this fiddle:http://jsfiddle.net/TdBdW/1/- apologies for the lack of css.As you can see, for my dynamically generated dropdowns and textboxes I have a big list of hardcoded values. I would have liked to have pulled these straight from a database but the queries take too long to run for them to be used in real-time - i.e. when the user clicks on a drop-down or tries to type in the auto-complete box.Instead what I would like to do is have the relevant queries run nightly using a cron job but the question is how to take the results of the query and put them into my javascript file.Anyone have any ideas how to implement this?Any help is greatly appreciated.Martin
Instead of using a hard coded values in JavaScript, is it possible to use a cron to do it?
Each Linux user has his own Cron scheduler to use. You can add jobs with the following command:crontab -eIn the text file that open you can schedule scripts to run using the following syntax:0 * * * * php /home/user/example.phpThis would run the script /home/user/example.php every hour. In the script you can do whatever processing or mailing you need.
In my Zend framework Project I want to create aCron Job. I.e., I want to send a mail to a particular email id ([email protected]) every 1 hrs. I read many docs. As per I have created a folder named Cron inViews->script. I have created a file namecronresult.phpalso I have created its controller page named cronController. But I don't know any further process.Where I put my php mail function - script to execute at every 1 hrs. I heard that need to create a crontab,where I create this Crontab file?Also I have one more doubt... When I logged to my cpanel,there is an option to ceate Cronjobs. SO is it possible to create a cron job from the cpanel?I don't know any Linux Command.. My project running in CGIPlease help me ..
Creating Cron job - doubt in crontab in zend
You have a*in your example where you need to put the start/end hours:0 8-20/y * * *Where you replaceywith the number of hours you want between runs should be fine. If you have some strange time like "1 hour and 15 minutes between runs", it's going to be a pain - probably just easier to calculate each time and enter it explicitly.
i need to run a job 'x' times a day. job timing is every (say 'y' hours) between 8am and 8pm. i read the documentation of cron between could not figure out how to place the "between times". any suggestion or a good tutorial should be really helpful.i could figure out this much.Found this in a tutorial. I believe this will serve the requiermentSimpleTrigger simpleTrigger = new SimpleTrigger("simpleTrigger", "triggerGroup-s1"); simpleTrigger.setStartTime(d); simpleTrigger.setRepeatInterval(1000*60*60*24); simpleTrigger.setRepeatCount(15); simpleTrigger.setEndTime(new Date(ctime + 60000L)); simpleTrigger.setPriority(10); scheduler.scheduleJob(jobDetail, simpleTrigger); scheduler.start();how could i modify the expression to serve my purpose.
cron job between 8am and 8pm 4 times at specified intervals of time
Using PHP, you could create a randomly named lock file in a directory specific to the cron job. Check for the number of lock files that exist in the directory before letting the PHP script continue. This may not be the best solution though.
I have a script written in PHP that is kicked off by a cron job. It's a long running script, and often cron kicks off another instance before the last is finished. That's fine. I allow 3 instances of this script to run at any given time.I limit the script to 3 instances with this code at the top of the script:exec('ps -A | grep nameofmyscript', $results); if (count($results) > 4) { echo "Already Running\n" die(0); }It works, but I'm looking for a better way. This approach backfired on me a few weeks back when I renamed the script, and forgot to change that line of code. It also fails when the script is named something similar to an already running process.
PHP/Cron Limit Number of Concurrently Running Scripts
The main difference is the environment variables.In this case it might be the PATH. lsof is often found in or /usr/sbin , that might be in your PATH when you run it interactivly, while not in the PATH when run from cron.try/usr/sbin/lsof|wc -lin your cron script. And check the local mail, as cron output is normally sent there, there might be relevant error messages.Is it related to pipe size as the result can be quite large?No.
I am trying to get the number of open files periodically through crontab using lsof|wc -l. It always returns zero. It is giving correct result when i run it directly.Any idea about this strange behaviour?Is it related to pipe size as the result can be quite large?Thanks a lot.Kaka
Different result when executed from Crontab
There is no UI for this on the Drupal core. Drupal cron will run all thehook_cron()implementations in the enabled modules. You can get all cron implementation on a Drupal site usingmodule_implements('cron').TheSuperCronorElysia Cronmodules can be used for more fine-grained control of the cron.
How can i edit the list of jobs that are going to run at running time of /DocRoot/cron.php in drupal??in other words, where can i edit the list of drupal jobs that return fromdrupal_cron_run?Thanks for your help
where can i find (edit) the jobs that are going to run in cron.php of drupal?
How about putting your countdown in an index.html and using a cron job (or similar) to delete it.And have a:before_filterin your application controller that does aredirect_to root_path unless Time.now > launch_timeNaturally, sometime after you launch, you'll want to remove the:before_filter...
I'm currently building a website for an awesome youth church we run (shameless plug!)..Anywho at the moment we have a static countdown pagehttp://mybase.co, and were having a massive launch this weekend and the site needs to go live when we launch,it's a rails app..How would you recommend scheduling it going live?having a cron job and an apache a2en?or is there a better way?ThanksDaniel
Cron Job to Schedule Rails Website Going Live?
Heroku's free cron addon runs only once a day, so it is not suitable. Their paid cron addon runs only once an hour, so it is also not suitable. Running a daemon/cron elsewhere is a hack that will become problematic very quickly. It's fundamentally bad architecture.Usingdelayed_jobwith a single Heroku Worker makes sense. Plus, delayed_job lets you specify exactly when each job should be run, down to a 5-second granularity. Yes, it is $36/mo to do this. But it frees you from doing things the wrong way. Plus, if you expect that you will not need the Worker most of the time, you can look into auto-scaling delayed_job on Heroku so the Worker is only turned on when you need it.
I have a table in my database with a list of emails to be sent, each at a specific time (precision down to the minute).I'm on heroku, and I don't want to spend anything right now.. Is there a way to do this? The only way I thought was to create a deamon/cron somewhere else and make it call a private url every minute.. any other idea? Any way to have some background process or something that can handle this (on Heroku and without paying extra for addons..)?thanks!
send delayed emails rails on heroku
You can do this astwocron jobs:0 0,3,6,9,12,15,18,21 * * * myprog myargs 30 1,4,7,10,13,16,19,22 * * * myprog myargsThis has the advantage of working on even ancient systems that don't support the/2-type syntax.
This question already has answers here:Closed13 years ago.Possible Duplicate:How can I set cron to run certain commands every one and a half hours?I know that every two hours is:* */2 * * * command-to-runbut how do I schedule acronjob to run every hour and a half?
How do I schedule a cron job to run every hour and a half? [duplicate]
You could put an extra environment variable in the crontab file:STAGING=1and then check for$_ENV['STAGING'] == 1.Or evenHOSTING_ENV=PRODUCTIONand then check for$_ENV['HOSTING_ENV'] == 'PRODUCTION'.
I'm building a website that will run a series of cron tasks daily to update information in a database that is then used in the site. I have three environments setup: development (my computer), staging and live. Both staging and live are accounts on shared hosting. The problem I have is in deciding which database access credentials to use depending on which environment the code is running on. Ideally all three would have the same credentials but as both staging and live are on a shared server I can't control the name of the database. I've mirrored the live database name and access credentials on my own computer but I can't do this on staging.What I want to do is to automatically select the correct credentials for the correct environment when my cron task runs, something like this:if(environment === staging) { //define db access constants for staging here else { //define db access constants for live or dev here }}Normally for this sort of thing I'd use $_SERVER['SERVER_NAME'] but as this is running in Cron the $_SERVER auto global isn't available. How could I detect on which environment a script is running in a cron job?
Detecting if a Cron job is running on a staging server
In order to store information in app-engine you need to use theDatastore.Seehereof an example. You probably need to create a model with two string properties, the google id and the auth token.
I'm writing some Google App Egnine + Android service for self and my friends. For each user this service will ask AuthSub token for another Google services. And by cron will retrieve information from this services and send it via c2dm on their cell phones.I need somewhere store user information and auth sub token for use it from cron. And if I understand correctly google app engine already has libs for this goal. Could you show me right direction for research (manuals, examples): - how to store auth sub token (I got it from gdata api); - how to retrieve it with google user id; - how to obtain all users data in cron jobs;PS: I'm c++ developer and it my first web app, sorry if this question is newbie.
Managing users data in app engine
As far as I know, WordPress just sets the publish date to some time in the future. It doesn't actually cause an event to happen in the future, it just looks that way when someone views the site.You'd need a cron job if you actually wanted to do something in the future, web servers only respond to requests made by user agents.
How to develop a schedule task system like the one used by Wordpress to schedule post? Do they use Cron Job? If they use it, how they configure it through PKP script?
How To Schedule Task With PHP?
Configure Cron to run your script every e.g. 1 hour and in script add code to check is RSS modified.EDIT:1. You can configure Cron to run your script every e.g. 1 hour.2. To the script, add the code to test whether the RSS has been modified.3. To check whether the feed was changed use the tag. You can save the tag content to txt and compare it.4. To write tag content you can useSimpleXMLandfwrite.
I have a script that sends out a push notification to users based on whats in a PHP file. This is that file ...the parts that matter ...$doc = new DOMDocument(); $doc->load('RandomXML Url location here '); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } // APPLE APNS EXAMPLE 1 $apns->newMessage(2); $apns->addMessageAlert($itemRSS['title']); // $apns->addMessageCustom('acme2', array('bang', 'whiz')); $apns->queueMessage(); // SEND ALL MESSAGES NOW $apns->processQueue();So thats the PHP that sends out the notification. It sends out the notification when this PHP script is loaded.It loads the first post from the feed and sends it out. I want to send a notification out every time the RSS feed is updated with a new post. If it is updated with a new feed, then I want to run the above code.So how can I do that and make sure it is run frequently?I would really like to see what code I need to check if its updated? I don't know how to check for updates though and thats probably the most important part of the script.
Run a PHP script when RSS feed updates (cron jobs?)
To edit cron tablecrontab -eYou can add an entry like this0,20,40 * * * * wget URL ~/files/file-`date > '+%m%d%y%H%M'`.html &To download/save the file every 20 mins.Here it is asmall referenceabout crontab expressions so you can adjust the valuesTo TAR the files automatically the crontab would be slightly complex:0,20,40 * * * * wget URL > ~/files`date '+%m%d%y'`/file-`date '+%H%M'`.html & * 12 * * * tar cvf ~/archive-`date '+%m%d%y'`.tar ~/files`date '+%m%d%y'`This would do it at noon, if you want to do it at mifnight it's more complex because you need to TAR the previous day but I think with this you'll get the idea.
Ok, so I know i can use:wget -r <website> > <file>to get a webpage and save it. My question is, how would i use cron and wget to get a webpage on an hourly, or even minute basis, and then save them into a folder, zip and tarball it, and then keep adding to it for a review at a later date.I know i can manually do this, my goal is to basically download it ever 10- 20 minutes, for roughly 4 hours (doesn't matter if it goes longer) and append the all into a nice directory, then zip said directory to conserve space, and check them later in the day.
Using wget and cron to download webpages
You can redirect the output to/dev/nulllike this:* * * * * my_command > /dev/nullIf an error occurs, you'll still get an email, though.
How can I disable the email on the cron?
Cron job: problem with crontab, it automatically sending me an email
How about:if (!array_key_exists("TERM", $_SERVER)) { exit; }
This question already has answers here:Closed13 years ago.Possible Duplicate:PHP - how to best determine if the current invocation is from CLI or web server?I know the obvious answer is to place the script outside the web root, but I'm hesitant to do that in my project since that complicates installation and might not even be possible in some shared hosting environments.I know some frameworks (CodeIgniter specifically) have a framework specific way of making sure a script cannot be called by navigating to it through a web browser, but I'm wanting a way to do this via stock PHP. Specifically, my script is designed to be called by cron. How can I make it so my script errors out if called in a web browser but executes correctly when called by cron?
How can I make a PHP script that cannot be called by a web browser? [duplicate]
Trysubject=$(</path/subject.txt) mailx -s "$subject"[email protected]< /usr/python/bi_python/launcher/test_output.txt
I have a crontab file which executes a shell script as shown below27 11 * * * /usr/python/bi_python/launcher/launch_script_leds.shThe shell script does a number of things:1)executes python script launcher.py which runs tests and outputs to log files2)sends mail notification when tests have completed with test output as body of the messageThis is the command in the .sh file:mail[email protected]< /usr/python/bi_python/launcher/test_output.txtThis works fine but subject is blankThe subject for the email is out put to a txt file subject.txt from launcher.py. Is there a way to make the contents of this file the subject of my mail message?I know you can use mail -s to specify subject but since many tests are being run through the launcher the subject will always varyThanks in advance
How can I make contents of a txt file be used as subject for mail in linux?
find . -name "*show1*" -exec cp {} /mnt/main/data/tv/Show1 \;(Replace the . by the directory you want to look files into)
New to bash scripting, I'm writing a script to copy my TV shows accross from a download folder to an archive folder.So far I have this:find `*`show1`*`.avi | cp \"" $0 "\" "/mnt/main/data/tv/Show1" find `*`show2`*`.avi | cp \"" $0 "\" "/mnt/main/data/tv/Show2"I understand this is not the best method, but my skills of bash are quite limited.I need to know how I can copy that found file, or do nothing if it doesnt find anything matching (this will be a cron script). eg.find `*`show1`*`.avi | cp "show1.hello.world.xvid.avi" "/mnt/main/data/tv/Show1" find `*`show2`*`.avi | cp "show2.foo.bar.xvid.avi" "/mnt/main/data/tv/Show2" find `*`show3`*`.avi | cp "null (nothing found)" "/mnt/main/data/tv/Show3"Thanks!EDIT: Solvedhttp://pastebin.com/aNLihR86
Bash copying files with variables