Response
stringlengths
8
2k
Instruction
stringlengths
18
2k
Prompt
stringlengths
14
160
41 Install rsyslog inside the container with apt-get install rsyslog and launch it with the command rsyslogd before starting cron with cron -L15 (maximum logging). Then watch the file /var/log/syslog inside the container to see the cron daemon's own log output. It will tell you if there was a problem parsing your crontab and it will, in your case, log an entry every minute similar to the below if it has registered and is trying to run your job. CRON[16]: (root) CMD (echo "Hello world" >> /var/log/cron.log 2>&1) Share Improve this answer Follow answered Nov 16, 2015 at 12:02 Dzamo NortonDzamo Norton 1,2841212 silver badges1818 bronze badges 2 3 I had the same issue under docker container. Your solution worked for me, but I had to create syslog file under /var/log (touch /var/log/syslog) and change it's owner to syslog:adm (chown syslog:adm /var/log/syslog). And with cron speaking to syslog, I've discovered this: /usr/sbin/cron[2990]: (root) INSECURE MODE (mode 0600 expected) (crontabs/root). So I had to set correct permission mode 0600 (chmod 0600 /var/spool/cron/crontabs/root). After that, everything worked fine. – Hudson Santos Apr 14, 2017 at 4:37 1 I also had this problem inside a Docker container. Installing rsyslog, starting it and running cron -L15 magically made my jobs run (I didn't even check the logs). So my cron job command had no errors. – arudzinska Sep 13, 2018 at 10:26 Add a comment Β |Β 
I have a simple Dockerfile as follows FROM ubuntu:latest ADD crontab /etc/cron.d/test-cron RUN chmod a+x /etc/cron.d/test-cron RUN touch /var/log/cron.log CMD cron && tail -f /var/log/cron.log and the content of crontab file is as simple as * * * * * root echo "Hello world" >> /var/log/cron.log 2>&1 # empty line When I run this on my local OS X machine (with docker-machine running), it works fine ("Hello world" is printed to log file every minute). However, when I try to run it on an Ubuntu machine, the cron job does not run (empty log file). Here's the command I use to run the container docker build -t crontest . docker run --name cron crontest I am not sure why this would be the case. I wonder if something is wrong with the Ubuntu box that I have (wrong time setting?). I have tried to restart that machine to no effect. I currently do have other docker containers running on the Ubuntu box and they're running fine. Any suggestion on what I could do to debug/ fix this would be hugely appreciated. EDIT: After going inside the container (docker exec -it cron /bin/bash), I can verify that cron is running there: root@a2ad451af8d9:/# ps -ef | grep cron root 1 0 0 20:15 ? 00:00:00 /bin/sh -c cron && tail -f /var/log/cron.log root 6 1 0 20:15 ? 00:00:00 cron root 7 1 0 20:15 ? 00:00:00 tail -f /var/log/cron.log root 25 11 0 20:21 ? 00:00:00 grep --color=auto cron
cron job not running inside docker container on ubuntu
Technically seen the php script is run where cron is located; ex. If cron was in /bin/cron, then this statement would look for common.php in /bin/includes/common.php. So yeah, you'll probably have to use fullpaths or use set_include_path set_include_path('/home/username123/public_html/includes/'); require 'common.php';
I have a cron job that needs to include this file: require '../includes/common.php'; however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron job runs the following file (on the live server): /home/username123/public_html/cron/mycronjob.php and here's the error: Fatal error: require(): Failed opening required '../includes/common.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username123/public_html/cron/mycronjob.php on line 2 using the same absolute format as the cron job, common.php would be located at /home/username123/public_html/includes/common.php does that mean i have to replace my line 2 with: require '/home/username123/public_html/includes/common.php'; ? thanks!
PHP: Require path does not work for cron job?
If the script is reporting errors, they may be going to stderr, but you're only redirecting stdout. You can redirect stderr by adding 2>&1 to the command: * * * * * /var/www/dir/sh/mysql_dump.sh 2>&1 | mail -s "mysql_dump" [emailΒ protected]
I have this line in crontab: * * * * * /var/www/dir/sh/mysql_dumb.sh | mail -s "mysql_dump" [emailΒ protected] (every minute only a sample) So, all works fine, but the email is empty. UPDATE: The output from mysql_dumb.sh is a *.sql file and they save the file in a directory. How can I send a copy (*.sql file) from this output -> mysql_dumb.sh to my email? mysql_dumb.sh: #!/bin/bash PATH=/usr/bin:/bin SHELL=/bin/bash /usr/bin/mysqldump -u USER -pPASS DATABASE > /var/www/dir/backup/backup_DB_`date +%d_%m_%Y`.sql
Cron Job - How to send an output file to an email
Real sh doesn't have source, only .. Either change the shell in cron to bash, or use . instead.
My cron : 45 10 * * * source /home/ThinkCode/Test/hello.sh hello.sh : #!/bin/bash echo "helloworld" The error it emails me : /bin/sh: source: not found What am I doing wrong? It is configuration/environment specific, so Googling didn't help much! Thanks..
Help with basic shell script. /bin/sh: source: not found
You may need to escape the % with a \. % is a special character to the crontab, which gets translated to a newline, so your code was probably becoming -p']T zw51' Try: -p']T\%zw51'
I am receiving an error with my Cron job. The error I keep getting is: /bin/sh: -c: line 0: unexpected EOF while looking for matching `'' /bin/sh: -c: line 1: syntax error: unexpected end of file Here is my code: mysqldump -u database_user -p']T%zw51' database > /home/site/public_html/Secure/Cron/Database_Backup/database_backup.sql
Why I'm getting unexpected EOF for my cron job?
How about the following: 0 0 * * 1,4 This sets the day of week to Monday (1) and Thursday (4). You can choose any values 0–7 (both 0 and 7 are Sunday). For a more readable crontab, you can also use names: 0 0 * * MON,THU See also: How to instruct cron to execute a job every second week?
How do I set a cron job to run twice a week? I know how to set a cron job for every week: 0 0 * * 0
How to set cron job for bi-weekly (twice a week)
Yes, the solution you specified is correct. 0,5,55 * * * * command # run the command at the top of the hour, at # the 5 minute mark and at the 55 minute mark.
With cron, if I wanted to run a command every 5 mins it would be: */5 * * * * command But what if I wanted to set a list of minutes specifically? Like at 5 past, 18 mins past and 15 minutes too the hour? I'm guessing this: 5,18,45 * * * *
Cron : Setting multiple minutes
I'm not entirely sure what you mean by "run my own cron tasks manually". For cron specifically, you need access to crontab, which they can control, as they're their servers. If you have another way of doing it, it would probably be fine, but bear in mind that your app is not tied to a specific server when running under Heroku, and that the server will change between executions. Also, unless they've changed it since last time I checked, you can run daily cron tasks for free, but hourly costs $3/mo. EDIT: Yes, daily crons are free. See http://addons.heroku.com/.
I've seen that Heroku charges $15/mo to run Delayed Job, and $3/mo to run cron tasks daily. Is it possible to skip that entirely and run my own cron tasks manually? Or are they somehow figuring out that I'm running cron tasks?
Running Cron Tasks on Heroku
This runs the script every minute of 2am (02:00, 02:01, 02:02 and so on): * 2 * * * While This runs the script at 02:13am (of each day of each month) 13 2 * * * * * * * * command to execute ┬ ┬ ┬ ┬ ┬ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, 7 is Sunday again) β”‚ β”‚ β”‚ └────────── month (1 - 12) β”‚ β”‚ └─────────────── day of month (1 - 31) β”‚ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59)
From what I have read, and wizard generators I have used the following should run the task every day at 2am * 2 * * * <my task here> However, looking at the logs it has actually fired the task for each minute in the 2am hour, in other words 60 times in total. What am I doing wrong here? Or are these generators just rubbish. Thanks
Setting cron task every day at 2am.. makes it run every minute
Assuming you are running the script directly through cron (as opposed to from a web server accessed by an HTTP request triggered by a cronjob (e.g. by cron running wget)), then of course it doesn't work. There is no server, so $_SERVER is not set.
I use $_SERVER['DOCUMENT_ROOT']."/lib/sft_required.php"; to include the 'sft_required' file in a PHP script. When I run this file using browser, it works fine but when I run this as a cron job job, it does not work. It seems that the file is not included when we run the script through cron.
$_SERVER['DOCUMENT_ROOT'] does not work in the php script running through cron
Cron needs to escape the % sign - http://www.hcidata.info/crontab.htm Try it with a backslash: 57 1 * * 2-6 ET=`date --date 'yesterday' +\%Y\%m\%d`;echo $ET
Herer is my CRONTAB file (Ubuntu 10.10): 57 1 * * 2-6 ET=`date --date 'yesterday'+%Y%m%d`;echo $ET Even The syntax color indicate that something is wrong. and there is this error: Subject: Cron <root> ET=`date --date 'yesterday' + (failed) Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> /bin/sh: Syntax error: EOF in backquote substitution But I am not sure whats wrong. Thanks a lot!
CRONTAB syntax error
Here's a workaround solution thanks to https://bugs.launchpad.net/ubuntu/+source/proftpd-dfsg/+bug The problem is due to ProFTPD not stopping in time to be restarted. The workaround is to edit the service file, to add a retry. /etc/init.d/proftpd Find this line: start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE" Change to this: start-stop-daemon --stop --signal $SIGNAL --retry 1 --quiet --pidfile "$PIDFILE" This change solved it for me. Suggestions for improvements are most welcome.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 9 years ago. Improve this question ProFTPD on Ubuntu is being killed unexpectedly. Log message: $ tail /var/log/proftpd/proftpd.log.1 ... ... ProFTPD killed (signal 15) ... ProFTPD 1.3.5rc3 standalone mode SHUTDOWN Diagnosis: the time of the message is the same time that cron runs the logrotate command. Google searches turn up various info about ProFTPD having a glitch on Debian-based systems due to log files, log rotations, and the ProFTPD server not restarting. I will add a bounty for a solution to this. I've posted a workaround answer too, in case it's helpful for others.
ProFTPD killed (signal 15) error - how to fix logrotate restart error? [closed]
Cron can be run in Amazon-based linux server just like in any other linux server. Login to console with SSH. Run crontab -e on the command line. You are now inside a vi editor of the crontab of the current user (which is by default the console user, with root permissions) To test cron, add the following line: * * * * * /usr/bin/uptime > /tmp/uptime Now save the file and exit vi (press Esc and enter :wq). After a minute or two, check that the uptime file was created in /tmp (cat /tmp/uptime). Compare it with the current system uptime by typing the uptime command on the command line. The scenario above worked successfully on a server with the Amazon Linux O/S installed, but it should work on other linux boxes as well. This modifies the crontab of the current user, without touching the system's crontabs and doesn't require the user inside the crontab entry, since you are running things under your own user. Easier, and safer!
I've spent two days trying to understand why I can not get cron to work on my Ubuntu EC2 instance. I've read the documentation. Can anyone help? All I want is to get a working cronjob. I am using a simple wget command to test cron. I have verified that this works manually from the command line: /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/ My crontab file looks like this: 02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/ I have single spaces between the commands and I have a blank line below the command. I've also tried to execute this command from the system level sudo crontab -e. It still doesn't work. The cron daemon is running: ps aux | grep crond ubuntu 2526 0.0 0.1 8096 928 pts/4 S+ 10:37 0:00 grep crond The cronjob appear to be running: $ crontab -l 02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/ Does anyone have any advice or possible solutions? Thanks for your time.
Cannot get cron to work on Amazon EC2?
Nothing in the description gives reason for it to be executed twice. Look elsewhere. Do two users call it? Is it entered twice? Does it call itself? Does it set in motion conditions for repetition? If it's a shell script you're executing, have it append whoami and date to a log file. You should be able to dig up the reason. UPDATE Type ps -A | grep crond, make sure crond isn't running twice.
*/5 * * * * my command This entry works but every 5 minutes it gets executed twice, why? In /var/log/cron it shows: Jun 16 22:20:01 Test CROND[12512]: (root) CMD (my command) Jun 16 22:20:01 Test CROND[12516]: (root) CMD (my command) So it's not from two users. It is only entered once with crontab -e -u root. The command is a php command.
Why is this cron entry executed twice?
29 Doing everything in one heredoc in the SCL environment is the best option, IMO: scl enable python27 - << \EOF cd /var/www/python/scripts/ python runAllUpserts.py >/dev/null 2>&1 EOF Another way is to run just the second command (which is the only one that uses Python) in scl environment directly: cd /var/www/python/scripts/ scl enable python27 "python runAllUpserts.py >/dev/null 2>&1" Share Improve this answer Follow answered Jul 2, 2013 at 9:07 slavekslavek 40133 silver badges44 bronze badges Add a comment Β |Β 
I've hit a snag with a shell script intended to run every 30 minutes in cron on a Redhat 6 server. The shell script is basically just a command to run a python script. The native version python on the server is 2.6.6 but the python version required by this particular script is python 2.7+. I am able to easily run this on the command line by using the "scl" command (this example includes the python -V command to show the version change): $ python -V Python 2.6.6 $ scl enable python27 bash $ python -V Python 2.7.3 At this point I can run the python 2.7.3 scripts on the command line no problem. Here's the snag. When you issue the scl enable python27 bash command it starts a new bash shell session which (again) is fine for interactive commandline work. But when doing this inside a shell script, as soon as it runs the bash command, the script exits because of the new session. Here's the shell script that is failing: #!/bin/bash cd /var/www/python/scripts/ scl enable python27 bash python runAllUpserts.py >/dev/null 2>&1 It simply stops as soon as it hits line 4 because "bash" pops it out of the script and into a fresh bash shell. So it never sees the actual python command I need it to run. Plus, if run every 30 minutes, this would add a new bash each time which is yet another problem. I am reluctant to update the native python version on the server to 2.7.3 right now due to several reasons. The Redhat yum repos don't yet have python 2.7.3 and a manual install would be outside of the yum update system. From what I understand, yum itself runs on python 2.6.x. Here's where I found the method for using scl http://developerblog.redhat.com/2013/02/14/setting-up-django-and-python-2-7-on-red-hat-enterprise-6-the-easy-way/
scl enable python27 bash
Running process has a PID and its fd (file descriptor) is mapping to /proc/<PID>/fd. And we can find PID of the running cron process at /var/run/crond.pid. To send cron log to stdout, we could write log to fd number 1 of the process started by cron. 0 9 * * * /bin/sh /bin/cleanup.sh > /proc/$(cat /var/run/crond.pid)/fd/1 2>&1
I have a cron job and its output is now redirected into a file. It looks like the following 0 9 * * * /bin/sh /bin/cleanup.sh > /home/darkknight/cleanup.log Can any one help me to rediect its output to stdout?
How to redirect cron job output to stdout
It seems to work for me, but I think you need to specify the editor: env EDITOR=nano crontab -e Add your crons, and then save the file with the name and location given. In my case it's a file in /tmp/crontab.xxxx. Then if you do crontab -l you should see your crons.
Question. Is cron supposed to work in OSX El Capitan? Background. I've used crontab for years on OSX, but with El Capitan it seems not to work. I added my username to /usr/lib/cron/cron.allow and even rebooted the machine, but still my cron jobs don't do anything, nor do they mail me with errors. The manpages suggest Apple doesn't want people using cron, but they don't say it is nonfunctional (yet).
is crontab broken on OSX El Capitan?
Original question was tagged cron so this first section applies to that. See below for an updated answer for the Quartz CronTrigger tool. Most crontabs don't let you specify the year so you'll probably have to put that in the script itself (or a wrapper around the script/program). You can do this with something like: # Only run in 2010. if [[ $(date +%Y) != 2010 ]] ; then exit fi The option you're looking for to run at 6am on September 6 every year is: 0 6 6 9 * your_command_goes_here β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └─ any day of the week. β”‚ β”‚ β”‚ └─── 9th month (September). β”‚ β”‚ └───── 6th day of the month. β”‚ └─────── 6th hour of the day. └───────── Start of the hour (minutes = 0). For the Quartz CronTrigger format, you'd be looking at something like: 0 0 6 6 9 ? 2010 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └─ 2010 only. β”‚ β”‚ β”‚ β”‚ β”‚ └───── any day of the week. β”‚ β”‚ β”‚ β”‚ └─────── 9th month (September). β”‚ β”‚ β”‚ └───────── 6th day of the month. β”‚ β”‚ └─────────── 6th hour of the day. β”‚ └───────────── Start of the hour (minutes = 0). └─────────────── Start of the minute (seconds = 0).
I want a cron expression that represents 6th September 2010 6:00 am
Cron expression for particular date
What you really want to use the the CronExpression object directly not the CronTrigger. As you discovered, it won't calculate next run times in the past... but CronExpression will! CronExpression has the method: getNextValidTimeAfter. This is what you want.
I'm using the Quartz CronTrigger facility to parse cron schedule format strings to determine when a specific job should run. I'm not actually using Quartz to schedule the job though. There is a method in CronTrigger called getFireTimeAfter(Date) which gives the next time the job will fire after the given date. This works well when the supplied date is now or in the future. But it doesn't seem to work if the date is in the past. Date currTime = new Date(); CronTrigger tr = new CronTrigger(); tr.setCronExpression("0 0 23 3,18 * ? *"); Date nextFireAt = tr.getFireTimeAfter(currTime); System.out.println("Reference time: " + currTime); System.out.println("Next fire after reference time: " + nextFireAt); Which is a cron schedule to fire at 23:00 on the 3 and 18 of every month. So for example, if I did this today (August 11), I see: Reference time: Thu Aug 11 10:04:25 MDT 2011 Next fire after reference time: Thu Aug 18 23:00:00 MDT 2011 But if I set the reference date to the past, it gives me the same next fire time. Reference time: Wed Dec 31 17:00:00 MST 1969 Next fire after reference time: Thu Aug 18 23:00:00 MDT 2011 I was expecting the output to be: Reference time: Wed Dec 31 17:00:00 MST 1969 Next fire after reference time: Wed Aug 3 23:00:00 MDT 2011 Is the method just not intended to work that way or am I doing something wrong? Thanks!
Quartz CronTrigger - Getting next fire time
33 At I/O 2019 it was announced a new feature to do cronjobs with firebase functions. Check it out schedule-functions Snippet 1 export scheduledFunction = functions.pubsub.schedule(β€˜every 5 minutes’).onRun((context) => { console.log(β€˜This will be run every 5 minutes!’); }); Snippet 2 exports.scheduleJobs = functions.pubsub. schedule(β€œevery day 03:00”).onRun(async() => { // do something console.log(β€œAll done! See you tomorrow morning!”); }); Share Improve this answer Follow answered May 9, 2019 at 16:18 GastΓ³n SaillΓ©nGastΓ³n SaillΓ©n 12.7k55 gold badges7171 silver badges7979 bronze badges 1 finally no need to deploy separately to gcloud! – Stanislau Buzunko May 18, 2019 at 11:56 Add a comment Β |Β 
I am trying to run a cron job with Firebase. Basically I need to run a function that makes a ton of API calls and pushes data to firebase at 12:00am PST every day. Is there a way for me to do this on the server side with Firebase? I see that there's this module here, but I don't understand how it works at all. If anyone has any ideas or know how the aforementioned module could work that would be fantastic. EDIT: Idea. What if I were to create a data entry that showed the time that the function was completed. Basically check to see that last time the function was called and completed. If it's past 12am then the function is called and the field is updated so it's not called until the next day. Would this be a good idea? I don't need the function to happen at 12am exactly, I just need it to be completed by the time the first user logs in.
How to run cron job with Firebase?
Edit cron with crontab -e and add the following: 0 */12 * * * /usr/bin/node /usr/bin/pm2 restart all For the schedule, use 0 */12 * * * for every 12 hours, or 0 0,12 * * * for 0:00 and 12:00 specifically. (Your schedule, * 0,12 * * *, would trigger every minute of hour 0 and hour 12, 0:00, 0:01, 0:02...) For the command, as fedorqui mentioned, use the path to node followed by the path to pm2 and the pm2 options. Use which node and which pm2 to get the path to node and pm2.
Tried this, but it doesn't work: SHELL=/bin/bash PATH=/usr/lib/node_modules/pm2/bin * 0,12 * * * pm2 restart all What am I doing wrong?
Restart pm2 app every 12h with cron
49 The format is second, minute, hour, day, month, weekday so the correct cron expression should be 0 0 */3 * * * If that doesn't work, what's the exact error message you are getting? Share Improve this answer Follow answered Sep 28, 2012 at 12:50 Christoph LeiterChristoph Leiter 9,21544 gold badges3131 silver badges3737 bronze badges 5 21 what is the difference between 0/3 and */3? – Ammad Feb 24, 2016 at 21:12 2 what is the difference 0/3 and */3? – shareef Jun 30, 2017 at 20:39 2 * means every possible value in the field. ? means you don't care about the value. It's used when you have two fields that may contradict each other. – Oleksandr Loushkin Oct 24, 2018 at 20:59 So I think */3 is every 3 hrs since the server started and 0/3 is every 3 hours where the hour is divisible by 3; so 3am, 6am, 9am, 12am, 3pm, 6pm, 9pm, 12pm. If anyone can confirm that would be great. – andrewps Apr 10, 2021 at 0:50 5 Ok I just ran a job with: 0 0 0/6 * * * to try for every 6 hours and it did work, it seemed to run every 6th whole hour after the server was started. I bounced it at 5:50pm and the job ran at 11pm, 5am, 11am. I would take a guess that */6 would run at exactly every 6 hours after the server was started in this case, 11:50pm, 5:50am and so on. So they both work but 0/6 is the 6th whole hour and */6 is exactly every 6 hours. – andrewps Apr 10, 2021 at 22:04 Add a comment Β |Β 
I want my spring batch job to run every 3 hours I used expression * * */3 * * ? this starts the job at the hour that is divisible by 3 e.g. say the server was started at 2 PM the job starts executing only at 3 PM - so far so good but the job keeps starting every second! Is it because I used * in the 1st position? I tried 0 0 */3 * * ? but it is erroring out. What is the best way to achieve this?
Spring batch Cron expression: to run every 3 hours
Here's what I recommend: 0 1 * * * php -q /home/user/cron/cron.php --task=task1 20 1 * * * php -q /home/user/cron/cron.php --task=task2 40 1 * * * php -q /home/user/cron/cron.php --task=task3 #etc... and then in your cron.php file you do: <?php // include libraries function getArguments() { $argument = array(); for($i = 1; $i < $_SERVER['argc']; ++$i) { if(preg_match('#--([^=]+)=(.*)#', $_SERVER['argv'][$i], $reg)) { $argument[$reg[1]] = $reg[2]; } } return $argument; } $argv = getArguments(); if($argv['task'] == 'task1') { // do task } elseif($argv['task'] == 'task2') { // do task }
i have multiple cronjobs that are setup as define: 0 1 * * * php -q /home/user/cron/cron1.php 20 1 * * * php -q /home/user/cron/cron2.php 40 1 * * * php -q /home/user/cron/cron3.php 0 2 * * * php -q /home/user/cron/cron4.php each of these cronjobs do different tasks but use the same libraries like phpmailer, pdf creator, geoip etc... how can i combine this cronjob into one so i dont have to create 50+ files that includes the same file over and over? thanks
multiple cronjob same php file
Celery is basically a RabbitMQ client. There are producers (tasks), consumers (workers) and AMQP message broker which delivers messages between tasks and workers. Knowing that will enable you to write your own celery in node.js. node-celery here is a library that enables your node process to work both as a celery client (Producer/Publisher) and a celery worker (Consumer). See https://abhishek-tiwari.com/post/amqp-rabbitmq-and-celery-a-visual-guide-for-dummies
Please suggest an equivalent of Celery in Node JS to run asynchronous tasks. I have been able to search for the following: (Later) Kue (Kue), coffee-resque (coffee-resque) cron (cron) node-celery(node celery) I have run both manual and automated threads in background and interact with MongoDB. node-celery is using redis DB and not Mongo DB. Is there any way I can change that?When I installed node-celery redis was installed as dependency. I am new to celery, Please guide.Thanks.
Equivalent of Celery in Node JS
7 From php.net manual: The php_sapi_name() function is extremely useful when you want to determine the type of interface. There is, however, one more gotcha you need to be aware of while designing your application or deploying it to an unknown server. Whenever something depends on the type of interface, make sure your check is conclusive. Especially when you want to distinguish the command line interface (CLI) from the common gateway interface (CGI). Note, that the php-cgi binary can be called from the command line, from a shell script or as a Cron Job as well! If so, the php_sapi_name() will always return the same value (i.e. "cgi-fcgi") instead of "cli" which you could expect. Do not always expect /usr/bin/php to be a link to php-cli binary. Luckily the contents of the $_SERVER and the $_ENV superglobal arrays depends on whether the php-cgi binary is called from the command line interface (by a shell script, by the Cron Job, etc.) or by some HTTP server (i.e. Lighttpd). Share Improve this answer Follow edited Jul 29, 2021 at 19:54 Yousha Aleayoub 5,12744 gold badges5454 silver badges6565 bronze badges answered Jan 16, 2020 at 6:45 gavintfngavintfn 50966 silver badges77 bronze badges 1 Currently "The PHP constant PHP_SAPI has the same value as php_sapi_name()." php.net/manual/en/function.php-sapi-name.php – Yousha Aleayoub Jul 29, 2021 at 20:01 Add a comment Β |Β 
Here is the line from my cron job... */5 * * * * php /home/user/public_html/index.php --uri=minion --task=emailassets When my script runs from this cron job, the PHP constant PHP_SAPI equals 'cgi-fcgi'. Why does PHP_SAPI not equal 'cli'?
Why does PHP_SAPI not equal 'cli' when called from a cron job?
To execute a job in UTC time zone, you can provide TimeZoneInfo as TimeZoneInfo.Utc while defining your jobs. RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily, TimeZoneInfo.Utc); To execute a job in local time zone you can use TimeZoneInfo.Local.
I am trying to configure a recurring task in my MVC application starting at 00:00 every day. I know this can be achieved by RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily);. Now my question is does hangfire cron work on basis of UTC time or the local time at server. If it works on local time, is there a way to run that on UTC time? I have to do this because this will be a day end process and all the scheduled tasks are scheduled based on the Universal time in my database.
Hangfire CRON in UTC time
I wrote a C# library that does just this. It's called cron-expression-descriptor. https://github.com/bradymholt/cron-expression-descriptor.
I am using Quartz.NET, and my scheduler relies heavily on the use of cron expression's - such as the ones detailed on this link: http://quartznet.sourceforge.net/tutorial/lesson_6.html Ideally, I'd like the 2 scenarios to be made possible (the 1st is probably much difficult, and less likely to be anything out there for it) 1: The ability for the user to construct a cron expression on an ASP.NET form, where they choose which minutes, hours, days etc 2: The ability to turn a cron expression into a short string, such as 'Every {x} minutes on Friday' or 'At {x} o clock on the last day of every month' I've begun writing my own versions of these, but it's a very hefty task and I'd love to find out there's a library out there, or even to have any hints and tips on this off you guys. Note: If there is nothing out there for this and I am (relatively) successful in creating the code, I'll gladly share the source if anyone wants it.
CronExpressions - any librarys out there to generate them/convert them into human readable form?
Can't use docker run -it --link [...] when running from cron - I use docker run --link [...] now.
I try to make automated (every night at 4) backups from a postgresql database running inside a docker container. #!/bin/sh CONTAINER=`docker ps|grep name_of_container|awk '{print $1}'` USER='postgre_user' PASSWORD='changed' BUDIR='/some/path/backup/' docker run -it --link $CONTAINER:db -v $BUDIR:/backup/ -e "PGPASSWORD=$PASSWORD" pg_dump -h db -U $USER -Fc -f /backup/$(date +%Y-%m-%d-%H-%M-%S).dump My crontab looks like this: 0 4 * * * /path/to/script.sh The script works fine when I execute it manually and it also get executed from cron (I tried * * * * * for debugging). I can't figure out how to make cron and the script work together. So far I tried: write variables to log file check output from crontab (* * * * * [...] &>cron.log) check output from docker exec [...] > output.log in script $CONTAINER contains the correct docker id when run from cron, cron.log and output.log are created but empty. Any ideas?
run "docker run" from crontab
short answer add this line to your dockerfile RUN sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/crond the long answer from what I understand issue is related to differences in the kernal between CoreOS & Unbutu. this in-turn causes a pam security issue. to figure it our first needed to turn on logging for cron (since we are in docker normal startup is not executed). run service rsyslog start service crond restart the cron log had this error (located here /var/log/cron) FAILED to open PAM security session (Cannot make/remove an entry for the specified session) so then I took a look at the security log, and it had this error (located here /var/log/secure) pam_loginuid(crond:session): set_loginuid failed some more googling and found I needed to modify my pam cond config (found here /etc/pam.d/crond) edit this file and comment out the following line #session required pam_loginuid.so restart crond and all should be good
Im trying to get a docker container running to mange my cronjobs im running a very simple cron as a test in a docker container using centOS 6.5 base * * * * * /bin/echo "it works!" >> test.log it works fine if the container is running on CoreOS host, however if I run the container on a ubuntu 13.10 host the cron is not executed. (I though the host did not effect what was running in the container) both hosts are running docker 0.8 am I missing something obvious, or it this a bug? thanks
Issues running cron in Docker on different hosts
The problem is that cron treats % as newlines. From crontab POSIX man page: Percent-signs (%) in the command, unless escaped with backslash \, will be changed into newline characters, and all data after the first % will be sent to the command as standard input. Also use Command Substitution syntax as $() over the legacy `` syntax as You could change your command to something like, */2 * * * * mongodump --db prodys --out /backup/databases/mongoDatabases/$(date +'\%m-\%d-\%y')
I created a new task in crontab as shown below : */2 * * * * mongodump --db prodys --out /backup/databases/mongoDatabases/`date +"%m-%d-%y"` I'm getting following error : /bin/sh: 1: Syntax error: EOF in backquote substitution Please help, I don't have any clue whats wrong.
/bin/sh: 1: Syntax error: EOF in backquote substitution
It turns out that the answer was easier than I expected. There is a --batch parameter missing, gpg tries to read from /dev/tty that doesn't exist for cron jobs. To debug that I have used --exit-on-status-write-error param. But to use that I was inspired by exit status 2, reported by echoing $? as Cd-Man suggested.
I have a script that has a part that looks like that: for file in `ls *.tar.gz`; do echo encrypting $file gpg --passphrase-file /home/$USER/.gnupg/backup-passphrase \ --simple-sk-checksum -c $file done For some reason if I run this script manually, works perfectly fine and all files are encrypted. If I run this as cron job, echo $file works fine (I see "encrypting <file>" in the log), but the file doesn't get encrypted and gpg silent fails with no stdout/stderr output. Any clues?
How to run gpg from a script run by cron?
Both should work, but I would probably use the second one.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 6 years ago. Improve this question I don't have a box to test a cron job so I am posting it here. I want to run a job every hour between 6 am to 18:00.This is what I have tried 0 6-18/1 * * * <command> and 0 6-18 * * * <command> Which one is the correct way of achieving it
cron every hour between 6 am to 18:00 [closed]
docker image prune provides a filter to remove images until a specific date: docker image prune -a --filter "until=$(date +'%Y-%m-%dT%H:%M:%S' --date='-15 days')"
Is there a way to remove built docker images some days ago? If we check docker images, will got: REPOSITORY TAG IMAGE ID CREATED SIZE There exists a CREATED item. Researched from the official document, didn't find an option for that.
How to remove docker images which created 7 days ago automatically?
The quickest way would be to edit the crontab file (which can be done by typing crontab -e) and simply comment the job you want disabled. Comment lines in crontab start with a #. 0 0 1 * * this_job_i_want.sh # uncomment below to enable # 0 0 2 * * this_job_i_dont_want.sh
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 2 years ago. Improve this question I need to quickly and temporarily disable a particular job in crontab under linux. How can I do that?
How to quickly disable a single job in crontab [closed]
First of all, you need to put an space between php and /var: From * * * * * php/var/www/html/welcome.php to * * * * * php /var/www/html/welcome.php ^ Then, you'd better use /bin/php instead of just php. To determine where the php executable is located, type which php in your console, it will give you the file path. So it will become something like this: * * * * * /bin/php /var/www/html/welcome.php ^^^^^^^^ More things: check if crontab is saved properly? Type crontab -l. Your new crontab line should be there. is the script exactly in this dir? Try /var0. is the script executing if you do from console? Try /var1 to see if it is a script or crontab problem. does the script have executing mode? Try /var2 Keep us updated so we can find what can be causing the error.
I've created a cron job in AWS EC2 but it is not working. I followed below steps to create cron tab: Step 1: I logged in to AWS EC2 Instace step 2: crontab -e Step 3: Insert mode Step 4: I entered * * * * * php/var/www/html/welcome.php (To run every min.) Step 5: :wq Cron tab is created but not running. Please can you any one help me if is there any PHP script means please provide me. Do I need to give spaces between every star?
How to write cron job in AWS EC2 server
The first element represents the seconds; to run at second 0 and 30 use the following: <cron-expression>0/30 0/1 * 1/1 * ? *</cron-expression>
I am using Quartz Scheduler to run my jobs. I want to run my job every thirty seconds. What will be my cron expression for that? For every one minute, I am using below cron expression: <cron-expression>0 0/1 * 1/1 * ? *</cron-expression> What it will be for every thirty seconds?
cron expression for every 30 seconds in quartz scheduler?
Is there a difference between the 2? Yes, indeed they are different. The difference is that with sudo crontab -e the commands are schedule with root user's credentials. So that the commands in the sudo's cron table are executed as root user. But with crontab -e, the commands are scheduled with the regular user who is logged in. Where should I put my cron command, should it be in sudo or without the sudo? Well, the answer to this depends on the type of command you want to run. If the command required sudo access then sudo crontab -e should be used. Else if the cron command doesn't require any special permission then use crontab -e. Example: If the ethernet network interface eth0 should be disabled or enabled at specific time then you would use the command ifconfig eth0 up or ifconfig eth0 down As the above commands require special permission (sudo), these commands are supposed to added to sudo's cron tab Any other command which require minimal permission or no permission like removing a file from root0 directory like root1 use the regular user's crontab.
I noticed that when I typed sudo crontab -e I dont see my cron command, but when I do only crontab -e there is my command. Is there a difference between the 2? If there is, where should I put my cron command, should it be in sudo or without the sudo? Thanks!
linux difference between "sudo crontab -e" and just "crontab -e"
That error means that GTK cannot find where X is running. It might be your DISPLAY variable is not set in the context that cron is trying to call your job. Try adding export DISPLAY=:0 To your .bashrc file if DISPLAY isn't set already. To test, enter the command echo $DISPLAY in a terminal and see what is printed out.
I use a website to order food, and I would like this website to be automatically opened in the browser at 11 am day. I opened crontab using "crontab -e" and tried this: 59 10 1-31 1-12 SUN,MON,TUE,THU google-chrome --new-window http://food.com and also tried this: 59 10 1-31 1-12 SUN,MON,TUE,THU x-www-browser http://food.com But they sent me an email instead of opening the website: (x-www-browser:16597): Gtk-WARNING **: cannot open display: (google-chrome:16883): Gtk-WARNING **: cannot open display: Thanks! Update: The solution was adding "export DISPLAY=:0 &&" to crontab. i.e.: 53 10 * 1-12 SUN,MON,TUE,THU export DISPLAY=:0 && google-chrome --new-window http://www.foodsite.com
How to set a cron job to open a web page in the browser using crontab?
14 It should work in the cron with following modifications: MAILTO="[emailΒ protected]" * * * * * echo blaah works on my server, just tested. Share Improve this answer Follow answered Mar 25, 2011 at 23:04 Scherbius.comScherbius.com 3,40644 gold badges2424 silver badges4444 bronze badges 6 Well, i think the " isn't the point (see bml's comment). But it is good to know, that the echo "blaah" works if the mail thing is installed correctly:) thanks for the help – Simon Lenz Mar 26, 2011 at 3:15 1 are the quotes needed? I am trying to debug my problem. – crh225 Apr 1, 2013 at 14:27 2 Quotes not needed, the following is perfectly valid [emailΒ protected],[emailΒ protected] – zsoobhan Dec 16, 2014 at 11:19 5 Quotes needed for no email! Took quite a while to figure out. – trss Jun 13, 2017 at 8:01 I did tried without quotes and It works as all email users received the email. In my case, it wasn't working because I was emailing the output and trying to write it to a file at the same time which means the following code, it won't work. [emailΒ protected],[emailΒ protected] * * * * * echo 'blah' >> /tmp/logs/blah.log – Sylvester Loreto Nov 9, 2018 at 12:21 Β |Β  Show 1 more comment
I'm running a script on my mybookworld(NAS) via crontab every day. And it would be nice if it could send me everyday an email report with the output of the script. So I looked at MAILTO in crontabs, but it doesn't send me anything at all. The script ran correctly at the right time, but there was no email. This is my crontab: ~ # crontab -l [emailΒ protected] 0 0 * * * python /root/erepCrawler/src/main.py I've written a "smaller" crontab for testing reasons: [emailΒ protected] * * * * * echo "blaah" This should send me every minute an email with "blaah" as the body. If I'm wrong please correct me. Is there another package needed for sending mails with crontab? sendmail is installed in /opt/sbin/sendmail.
mailto crontab doesn't work
Via the script you can create a "lock" file. If the file exists, the cronjob should skip the run ; else it should proceed. Once the script completes, it should delete the lock file. if [ -e /home/myhomedir/rsyncjob.lock ] then echo "Rsync job already running...exiting" exit fi touch /home/myhomedir/rsyncjob.lock #your code in here #delete lock file at end of your job rm /home/myhomedir/rsyncjob.lock
I have checked for a solution here but cannot seem to find one. I am dealing with a very slow wan connection about 300kb/sec. For my downloads I am using a remote box, and then I am downloading them to my house. I am trying to run a cronjob that will rsync two directories on my remote and local server every hour. I got everything working but if there is a lot of data to transfer the rsyncs overlap and end up creating two instances of the same file thus duplicate data sent. I want to instead call a script that would run my rsync command but only if rsync isn't running?
Rsync cronjob that will only run if rsync isn't already running
You're probably looking for 0 */45 * * * * The ranges are here. Seconds: 0-59 Minutes: 0-59 Hours: 0-23 Day of Month: 1-31 Months: 0-11 Day of Week: 0-6
I'm using node-cron to run scheduled jobs. I want the jobs to run every 45 minutes, but its acting strangely Here's the pattern I'm using '00 */45 * * * *' I started my script at Tue Jun 17 2014 08:17:39 GMT+0000 (GMT) Here's are the first couple of times the job was executed 1. Tue Jun 17 2014 08:45:03 GMT+0000 (GMT) 2. Tue Jun 17 2014 09:00:01 GMT+0000 (GMT) 3. Tue Jun 17 2014 09:45:02 GMT+0000 (GMT) This is definitely not what I expected or want. All I want is to run the Jobs every 45 minutes. Can anyone help me with the pattern? Thanks :)
Run Cron Job every 45 minutes with Node-Cron
Finally I have solved how to run the gem Whenever. It's working good on production, but not in development mode (I think that to working good in dev mode you must do some tricks). Then, these are the processes to do: install the gem write your scheduler.rb file push to the remote server login to the remote server (for example with ssh) see if whenever is good uploaded by running in terminal: whenever update whenever crontab by running: whenever --update-crontab restart the server crontab (for example in Ubuntu server): sudo service cron restart check if crontab is good implemented on the server: crontab -l That's it! Personally, I prefer to set up my crons directly from the server: Edit the crontab: crontab -e Append my cron (e.g. every day at 5:00 AM - can be little different for not-Linux-based server): 0 5 * * * /bin/bash -l -c 'cd /path_to_my_app/current && RAILS_ENV=production bundle exec rake my_cron_rake' Check if good implemented: crontab -l Done
I have an application that contains a bunch of tasks, and every day I want to run a cron job that creates a DayTask for each Task in the database. A Task has_many DayTasks and these daytasks are what users will be checking off every day. I'm using the whenever gem but it doesn't seem to be running at all. Any ideas? config/schedule.rb every 1.day, :at => "12:01am" do runner "Task.generate_tasks_for_day" end Task.rb def generate_tasks_for_day Task.all.each do |task| task.day_tasks.create(:target_date => Date.today) end end result of running the 'whenever command' 1 0 * * * /bin/bash -l -c 'cd /home/grant/rails_projects/GoalTwist && script/rails runner -e production '\''Task.generate_tasks_for_day'\''' Note: I've been changing the times in config/schedule.rb every time I want to test run it.
Cron job not working in Whenever gem
You've tagged your question as Laravel 4, but I don't think the scheduler was introduced until Laravel 5... Anyway, based on the code snippet you've posted, you could use the cron method. $schedule->command('catalog:update')->cron('0 */2 * * *'); // every 2 hours $schedule->command('catalog:update')->cron('0 */5 * * *'); // every 5 hours See the docs for other options. https://laravel.com/docs/5.4/scheduling#defining-schedules
I undestand that you can create hourly tasks on Laravel by using: $schedule->command('catalog:update')->hourly(); however is there a way to do for example every 2 hours or 5 hours? I couldn't find it on documentation or here.
Laravel Task Scheduling Every X Hours
Right solution: * 11,16,21 * * * Because if you use previous solution: 0-59 11-12,16-17,21-22 * * * * Job will start at 12:40 or 17:59. It is not in range from 11AM to 12AM, 4PM to 5PM and 9PM to 10PM. UPDATE: Traditional (inherited from Unix) cron format consists of five fields separated by white spaces: * * * * * command to be executed ┬ ┬ ┬ ┬ ┬ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └───── day of week (0 - 6) (0 is Sunday, or use names) β”‚ β”‚ β”‚ └────────── month (1 - 12) β”‚ β”‚ └─────────────── day of month (1 - 31) β”‚ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59) nnCron can use both traditional and "enhanced" version of cron format, which has an additional (6th) field: Year.
How do you run a cron job every minute only on specific hours? Like so: It will only check every minute from 11AM to 12AM, 4PM to 5PM and 9PM to 10PM It seems to be complicated to me I don't know where to start.
Run a cron job every minute only on specific hours?
I solved this problem including PATH into bash file #!/bin/bash cd /myfolder/crawlers/ PATH=$PATH:/usr/local/bin export PATH scrapy crawl my_spider_name
I want to execute my scrapy crawler from cron job . i create bash file getdata.sh where scrapy project is located with it's spiders #!/bin/bash cd /myfolder/crawlers/ scrapy crawl my_spider_name My crontab looks like this , I want to execute it in every 5 minute */5 * * * * sh /myfolder/crawlers/getdata.sh but it don't works , whats wrong , where is my error ? when I execute my bash file from terminal sh /myfolder/crawlers/getdata.sh it works fine
Scrapy crawler in Cron job
* * * * * sleep 10;curl http://www.google.com/
Simple question: I want to run a cron operation every minute at the 10th second (for example at 2:00:10 PM). The cron operation runs a curl command to download a website page. How can I run a cron operation to do that? Current crontab setting: * * * * * curl http://www.google.com/
How to sleep 10 seconds before running a linux command?
It always splits the current hour only. 40/40 = 1 so it runs every 40th minute of an hour. */5 would do 5, 10, 15... You should go for larger intervals. Do */30 for your 25 minute interval and every 60 minutes for your 40 minutes interval. Otherwise set up two crontabs for your script: 0,40 */2 * * * /path/to/script/foo.sh 20 1,3,5,7,9,11,13,15,17,19,21,23 * * * /path/to/script/foo.sh
I want a script to run every 40mins beginning on the 40th minute. so that means: 00:40, 01:20, 02:00, 02:40, 03:20... So I made this entry to cron: */40 * * * * /path/to/script/foo.sh Unfortunately this runs the script every 40th minute of the hour: 00:40, 01:40, 02:40... The same goes with the script that I meant to run every 25mins. Am I missing something here? ANSWERS Alright, in case you happen to drop by here having the same problem here's how I solved it: # 40mins-interval 40 0 * * * /path/foo.sh (0) 0,40 2-22/2 * * * /path/foo.sh (2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22) 20 1-23/2 * * * /path/foo.sh (1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23) # 25mins-interval 25,50 0 * * * /path/foo.sh (0) 0,25,50 5-20/5 * * * /path/foo.sh (5, 10, 15, 20) 15,40 1-21/5 * * * /path/foo.sh (1, 6, 11, 16, 21) 5,30,55 2-22/5 * * * /path/foo.sh (2, 7, 12, 17, 22) 20,45 3-23/5 * * * /path/foo.sh (3, 8, 13, 18, 23) 10,35 4-19/5 * * * /path/foo.sh (4, 9, 14, 19) Notes: 1. There will still be collisions in this schedule (i.e: see schedules that run on the 0th and 10th minutes on both intervals). 2. The script won't run at an exact interval from its last run today going on the next day (i.e: 25min interval ends @23:45 today, begins @00:25 next day).
How do set cron to run my script every 40mins/25mins?
Symfony2 does not manage cron tasks, simply because this is system level. That being said, you can create a command and register it as a cron task.
I have a little question, how create a simple cron task who call some service action in Symfony, who could be executed automatically each night ?
How to create a cron task in Symfony2
By default, execution is blocking and single-threaded, which means they will not run concurrently. If you want jobs to run simultaneously, you can annotate the method as @Async as well. You may also want to look at the different Executors. If you're using fixedDelay like in the sample question you provided, the next job will only kick off AFTER the current one is over, plus the delay. So if your job takes 10 hours and you have a fixedDelay of 5000, the next job will kick off 5 seconds after the 10 hour one. If you're using fixedRate then the next scheduled event will be queued up to run, but not skipped, as per the documentation: If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute. If you are simply using cron, then the jobs will be queued and executed in turn (similar to fixedRate). You can test this with a simple method (below is in Groovy, but can use plain Java too): int i = 0 @Scheduled(cron = '* * * * * * ') void test() { if (i < 5) Thread.sleep(10000) i += 1 println '------------------------' + i // No values skipped } You'll note that every number is printed; e.g. no cycle is ever skipped.
I have a job that runs once an hour, and I'm using Spring's @scheduled cron to schedule it. If the job takes more than an hour, I understand from How to prevent overlapping schedules in Spring? that the next job won't kick off while the first job is running. But does this mean that it WILL kick off after the first job has completed, or has it missed its chance? If I have one job that takes 10 hours, will all the missed cron jobs queue up and then execute one by one when the first job completes after 10 hours, or will just the first job run? Thanks!
What is the expected behaviour of spring @scheduled cron when jobs would overlap?
Possibly you want to specify PATH β€” and also ORACLE_HOME and LD_LIBRARY_PATH β€” so that cron(1) knows where to find binaries. Read "5 Crontab environment" here.
I want to schedule a task on Linux by icrontab, and the task is written in python and have to import cx_Oracle module, so I export ORACLE_HOME and LD_LIBRARY_PATH in .bash_profile, but it raise the error: libclntsh.so.11.1: cannot open shared object file. Since it is ok to run the task by issue the command in shell like: python a.py # ok I change the task in icrontab into a shell script which invoke my Python script, but the exception recurred? # the shell script scheduled in icrontab #! bash python a.py Could you help how to do with it?
libclntsh.so.11.1: cannot open shared object file.
You can set an environment variable in your crontab. A line like IS_CRON=1 can be placed at the beginning of your crontab, then check in your php program for get_env("IS_CRON") == 1. Of course, you should also use file permissions as they're not so easily bypassed. If this is run as part of root's cron, chown root:root yourscript.php and chown 700 yourscript.php. As ircmaxell says, it'd be better to run as a user other than root assuming you don't need root permissions for what you're doing. I was just taking a guess about your setup.
How can I ensure a user can not run a PHP script and that it is only ever run as part of a cron job?
Ensure a PHP script is only ever run as a cron job?
I would do this with two separate constructs. For after the application starts, use @PostConstuct, and for every night at midnight use @Scheduled with the cron value set. Both are applied to a method. public class MyClass { @PostConstruct public void onStartup() { doWork(); } @Scheduled(cron="0 0 0 * * ?") public void onSchedule() { doWork(); } public void doWork() { // your work required on startup and at midnight } }
How to describe Spring scheduler which is run after application is started and after 00:00 ?
Spring scheduler which is run after application is started and after midnight
You need to use add_action() to hook your function to the scheduled event. add_action( 'isa_add_every_three_minutes', 'every_three_minutes_event_func' ); Here is the full code. // Add a new interval of 180 seconds // See http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules add_filter( 'cron_schedules', 'isa_add_every_three_minutes' ); function isa_add_every_three_minutes( $schedules ) { $schedules['every_three_minutes'] = array( 'interval' => 180, 'display' => __( 'Every 3 Minutes', 'textdomain' ) ); return $schedules; } // Schedule an action if it's not already scheduled if ( ! wp_next_scheduled( 'isa_add_every_three_minutes' ) ) { wp_schedule_event( time(), 'every_three_minutes', 'isa_add_every_three_minutes' ); } // Hook into that action that'll fire every three minutes add_action( 'isa_add_every_three_minutes', 'every_three_minutes_event_func' ); function every_three_minutes_event_func() { // do something } ?>
there are many post on stackoverflow with this topic but (i dont know why) nothing will work for me. What i have function isa_add_every_three_minutes( $schedules ) { $schedules['every_three_minutes'] = array( 'interval' => 180, 'display' => __( 'Every 3 Minutes', 'textdomain' ) ); return $schedules; } add_filter( 'cron_schedules', 'isa_add_every_three_minutes' ); function every_three_minutes_event_func() { // do something } wp_schedule_event( time(), 'every_three_minutes', 'every_three_minutes_event_func' ); Any ideas what i'm doing wrong?
Wordpress cronjob every 3 minutes
The more recent versions of k8s (from 1.10 on) support the following command: $ kubectl create job my-one-time-job --from=cronjobs/my-cronjob Source is this solved k8s github issue.
Is there a simple way to change the schedule of a kubernetes cronjob like kubectl change cronjob my-cronjob "10 10 * * *"? Or any other way without needing to do kubectl apply -f deployment.yml? The latter can be extremely cumbersome in a complex CI/CD setting because manually editing the deployment yaml is often not desired, especially not if the file is created from a template in the build process. Alternatively, is there a way to start a cronjob manually? For instance, a job is scheduled to start in 22 hours, but I want to trigger it manually once now without changing the cron schedule for good (for testing or an initial run)?
How to change the schedule of a Kubernetes cronjob or how to start it manually?
/var/spool/cron/crontabs is the usual parent directory for crontab files. There are files there that have names of users - root is the root crontab, for example. There is a potential for every user on the system to have used crontab -e and created his/her own crontab. As root you can : cd /var/spool/cron/crontabs grep 'search string' * This command (as root) will tell you what user's crontab has the string. And if it exists. You would do this if if you are not sure what crontabs things are in. crontab -l only gives the stuff in YOUR crontab, the user who is currently logged in. If you are sure that is the best place to check: crontab -l | grep -q 'search string' && echo 'entry exists' || echo 'entry does not exist'
I am trying to find a cronjob that was created to ensure that the script doesn't duplicate the same exact cronjob. I've been trying to use something along these lines but haven't had much luck: if ! crontab -l | xargs grep -l '/var/www/arix/update.php'; then echo "Cronjob already exists" else echo "Cronjob doesn't exist" fi
Search for a cronjob with crontab -l
If you are using Fabric for deploment you could add a function that edits your crontab. def add_cronjob(): run('crontab -l > /tmp/crondump') run('echo "@daily /path/to/dostuff.sh 2> /dev/null" >> /tmp/crondump') run('crontab /tmp/crondump') This would append a job to your crontab (disclaimer: totally untested and not very idempotent). Save the crontab to a tempfile. Append a line to the tmpfile. Write the crontab back. This is propably not exactly what you want to do but along those lines you could think about checking the crontab into git and overwrite it on the server with every deploy. (if there's a dedicated user for your project.)
How do people deploy/version control cronjobs to production? I'm more curious about conventions/standards people use than any particular solution, but I happen to be using git for revision control, and the cronjob is running a python/django script.
How do you deploy cron jobs to production?
Crontab needs the full path on your server. 0 0 * * * php /var/www/vhosts/domain.com/httpdocs/scripts/example.php This will execute every day at midnight.
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. Closed 10 years ago. I would like to run a PHP script every day at midnight. After research on how to do this, it appears that the best way to achieve this is to use a CRON job. If my php script was located at http://example.com/scripts/scriptExample.php, can somebody be able to show the most simple example of what this CRON command would look like? I have looked through numerous posts but I cannot find a simple enough example for me to learn and build upon.
Executing a PHP script with a CRON Job [closed]
24 The nvm command is not a file but rather a shell function. The source ~/.nvm/nvm.sh adds these functions to your current shell. And because these commands are not files, they don't show up when you which nvm. Looking in the .nvm/nvm.sh file, you can see a nvm() {...} function defined that provides that functionality. Cron is likely using as different user, and that user needs to have source ~/.nvm/nvm.sh added to its shell context before running. Share Improve this answer Follow answered Nov 8, 2014 at 18:52 Mike Biglan MSMike Biglan MS 1,86211 gold badge2020 silver badges2020 bronze badges Add a comment Β |Β 
I installed NVM on an ubuntu machine, but, when I put it in the crontab for execution during reboot: @reboot nvm use 0; it didn't work, and I got a mail from the cron daemon, saying: /bin/sh: 1: nvm: not found So, I thought this a path problem, and tried to find where NVM is installed. To my surprise, I got empty results: root@vps-1145280-18735:~# which nvm root@vps-1145280-18735:~# But, NVM itself does work, even after reboot: root@vps-1145280-18735:~# nvm Node Version Manager ... This is very strange - how can it be that the system finds the nvm program, when the "which nvm" is empty?! And, more important - what should I do in order to have the cron program find NVM during startup?
"which nvm" is gone
21 To guard against restarts you need to create a persistent data stored job. Something like : Job = { _id: Number, job: String, dueDate: Date, completed: Boolean } Then have some code as follows: var createJob = function(url, date) { var j = db.create(Job, function(j) { j.job = url; j.dueDate = date; j.save(); }); }; var runJob = function(j) { var id = j._id; setInterval(j.dueDate - Date.now(), function() { db.getOne(Job, { _id : id }, function(j) { require(j.job); j.finished = true; j.save(); }); }); j = null; }; On start up you just have to do something like : db.get(Job, { finished: false }, function(jobs) { jobs.forEach(runJob); }); Replace the generic db with MongoDB, CouchDB, Redis, etc. Share Improve this answer Follow edited May 22, 2013 at 0:06 hexacyanide 89.5k3131 gold badges160160 silver badges162162 bronze badges answered Apr 12, 2011 at 13:51 RaynosRaynos 168k5757 gold badges354354 silver badges396396 bronze badges 1 Suppose there are multiple cron jobs are running, is there any way just simply kill one of them? Because I encountered a scenario I needed to kill one job and did some other maintenance but I still wanted other jobs running. thanks! – zs2020 Apr 24, 2013 at 19:27 Add a comment Β |Β 
Is there a possibility to periodically call functions at a specific time of the day in node.js? My first implementation was setInterval(functionName(),(24*60*60*1000)); This is suboptimal, because it will restart every time I restart node. Are there better possibilities to implement this?
Cronjobs in node.js
As documented in Chapter 23. Scheduling and Thread Pooling, Spring has scheduling support through integration classes for the Timer and the Quartz Scheduler (http://www.quartz-scheduler.org/). For simple needs, I'd recommend to go with the JDK Timer. Note that Java schedulers are usually used to trigger Java business oriented jobs. For sysadmin tasks (like the example you gave), you should really prefer cron and traditional admin tools (bash, etc).
In a java web application (servlets/spring mvc), using tomcat, is it possible to run a cron job type service? e.g. every 15 minutes, purge the log database. Can you do this in a way that is container independent, or it has to be run using tomcat or some other container? Please specify if the method is guaranteed to run at a specific time or one that runs every 15 minutes, but may be reset etc. if the application recycles (that's how it is in .net if you use timers)
Is it possible to run a cron job in a web application?
2 I think you may need to look at your actual server cron configuration. Laravel scheduler requires the server cron to be run every minute for all schedules to run at the desired time. You may just have the cron running at 8.00am every day instead of every minute. It may be worth a check, I know I had difficulty with the same issue when I first started scheduling. When using the scheduler, you only need to add the following Cron entry to your server. If you do not know how to add Cron entries to your server, consider using a service such as Laravel Forge which can manage the Cron entries for you: * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1 This Cron will call the Laravel command scheduler every minute. When the schedule:run command is executed, Laravel will evaluate your scheduled tasks and runs the tasks that are due. Share Improve this answer Follow answered Jul 6, 2018 at 11:57 Sam KillenSam Killen 5155 bronze badges Add a comment Β |Β 
I am trying to run multiple jobs in Laravel at different times. This is the code: protected function schedule(Schedule $schedule) { $schedule->command('emails:send')->dailyAt('08:00'); $schedule->command('emails:evening-status')->dailyAt('17:00'); $schedule->command('email:weekly-report')->weekly()->mondays()->at('08:00'); } The problem here is that only the first command emails:send works. The other commands don't work at the specified time. However, when I run them manually they work fine. What is it that I am missing?
Schedule multiple crons in Laravel
43 The crontab for "everyday at 12:20am" is 20 0 * * * The whole line in crontab would then be 20 0 * * * /usr/bin/ruby /Users/tamer/scripts/sftp.rb Share Improve this answer Follow answered Sep 6, 2011 at 21:50 Bohemian♦Bohemian 419k9797 gold badges587587 silver badges736736 bronze badges 0 Add a comment Β |Β 
I am trying to write a cron job on my Mac OS X machine that will run a Ruby script at 12:20am everyday. This is what I need to run but I don't know the syntax or the command to use on the Mac: /usr/bin/ruby /Users/tamer/scripts/sftp.rb I read about doing crontab -e but do I need to do something afterwards?
How do I create a cron job that will run everyday at 12:20am?
In order to retrieve a specific job, you could create it with a unique name and you can retrieve it later via that unique name: var j = schedule.scheduleJob(unique_name, date, function() { }); // later on var my_job = schedule.scheduledJobs[unique_name]; my_job.cancel();
I am planning on using node-schedule to set up push notifications for appointment reminders as follows: var schedule = require('node-schedule'); var date = req.body.date; // Date for reminder from client request var j = schedule.scheduleJob(date, function(){ // Send push notification }); Now I know you can cancel the event by calling cancel(): j.cancel() However, how can I refer to that specific job to cancel if the user from the client side decides to change the appointment to a different date? Thanks in advance for your help!
Cancel node-schedule event after it has been set
There is a space between the #! and the /bin/sh. I don't think this is the reported problem but it needs fixing * I guess that you are using a version of Unix or Linux where /bin/sh is not bash so the export syntax is wrong. Alter your script to say PASSPHRASE=foo export PASSPHRASE See this answer UNIX export command * it's not a problem, see comments
Works just fine when running it manually on the shell but when I setup a cronjob to run it on reboot I get "bad variable name". #! /bin/sh # /etc/init.d/duplicityCleanUp export PASSPHRASE=foo duplicity remove-older-than 30D --force --gio smb://remote/archiv/ duplicity remove-all-but-n-full 1 --force --gio smb://remote/archiv/ unset PASSPHRASE
"bad variable name" in bash script started by cron
37 I was able to get my crontab (which calls python) back on track by giving /usr/sbin/cron "Full Disk Access". It's important to note that simple cron jobs were still executing, but my python based jobs were returning "Operation not permitted". The link that andrea_grioni is on the right track, but aims at giving terminal permission to edit the crontab. This was merely a convince in my case by removing the "allow/deny" dialog. link: Here is a more appropriate link. Share Improve this answer Follow answered Dec 11, 2019 at 18:45 MitchMitch 53033 silver badges77 bronze badges 2 4 Wow i was stuck on this for hours. The link's instructions are great. – Brendan Metcalfe Apr 7, 2020 at 0:05 1 so simple. so difficult to find – felixmp Jun 8, 2021 at 8:04 Add a comment Β |Β 
I have a very simple python script that works when I execute manually. However when I set up a crontab, it finds the script but returns the error "[Errno 1] Operation not permitted". I tried to set up a root crontab with the command sudo crontab -e but the same error occurs. Here's my crontab: * */1 * * * /usr/bin/python /absolute_path/test.py > /absolute_path/cron_log_test.log 2>&1 Edit: Everything was working great until I updated to macOS Catalina.
Crontab can't execute python script with error: "[Errno 1] Operation not permitted"
35 You can source cron jobs from a file into your crontab using crontab /path/to/cron/file/name To make it more explicit for readability's sake, use the arrow < for sourcing. crontab < /path/to/cron/file/name Sourcing the cron jobs this way can throw error errors in crontab file, can't install in case the crontab entry you have are syntactically invalid in terms of scheduling, so make sure the cron entries are correct. Also note that this will completely discard existing cronjobs and load the ones which are there in the file you pass, so it might help to save existing cron entries in a file using crontab -l > cron.backup EDIT In case you are looking for a way to change your default editor (to gedit or vi or something else) and not for a way to source cronjobs from file, you can export the VISUAL and EDITOR Path variables export VISUAL=vim export EDITOR=vim Share Improve this answer Follow edited Oct 18, 2013 at 17:25 answered Oct 18, 2013 at 16:36 Anshul GoyalAnshul Goyal 74.9k3838 gold badges155155 silver badges192192 bronze badges Add a comment Β |Β 
Anyone know a way to give a file into crontab -e ? I cannot use the regular form of crontab giving it a path but still need to replace the whole contents. Perhaps setting EDITOR to something?
replace crontab file with -e
19 Yes you can run its own, cron in specific user without sudo, As each user will be having the crontab file no need to install it explicitly. to run crontab of any user, use -u option , please note that user must be privileged to use -u $ crontab -u <username> -e Share Improve this answer Follow edited Dec 6, 2017 at 7:59 Jithin Scaria 1,28111 gold badge1515 silver badges2727 bronze badges answered Dec 6, 2017 at 7:01 sanath metisanath meti 5,76511 gold badge2323 silver badges3030 bronze badges 2 6 crontab: must be suid to work properly I am getting this error – LazyCoder Feb 13, 2018 at 11:49 Related: stackoverflow.com/a/36714096/5113030 (Failed to edit crontab (Linux Alpine)...) – Artfaith Sep 8, 2022 at 15:59 Add a comment Β |Β 
Error : crontab: must be suid to work properly I want to set cronjob in docker container with non-root user. Is it possible to set a cron without using sudo and without installing cron? I am using alpine docker container.
How to set cronjob with non-root user?
18 su --shell=/bin/bash --session-command="/path/to/command -argument=something" username & Works for me (CentOS) Share Improve this answer Follow answered Feb 18, 2011 at 3:42 KittyKitty 18111 silver badge22 bronze badges 3 I had to add export TERM=xterm; before my command inside the --session-command variable. Thus, I ended up with su --shell=/bin/bash --session-command="export TERM=xterm; /path/to/command -argument=something" username & – Steve Tauber Jun 26, 2012 at 18:09 Does not work on Ubuntu (12.04) as the su command doesn't support the --session-command option. – Lambart Jan 14, 2014 at 21:07 to clarify the answer, in root's crontab, add the su --shell=/bin/bash --session-command="/path/to/command -argument=something" username – NoelProf Feb 19, 2014 at 3:29 Add a comment Β |Β 
I seem to be stuck between an NFS limitation and a Cron limitation. So I've got root cron (on RHEL5) running a shell script that, among other things, needs to rsync some files over an NFS mount. And the files on the NFS mount are owned by the apache user with mode 700, so only the apache user can run the rsync command -- running as root yields a permission error (NFS being a rare case, apparently, where the root user is not all-powerful?) When I just want to run the rsync by hand, I can use "sudo -u apache rsync ..." But sudo no workie in cron -- it says "sudo: sorry, you must have a tty to run sudo". I don't want to run the whole script as apache (i.e. from apache's crontab) because other parts of the script do require root -- it's just that one command that needs to run as apache. And I would really prefer not to change the mode on the files, as that will involve significant changes to other applications. There's gotta be a way to accomplish "sudo -u apache" from cron?? thanks! rob
How do I run a command as a different user from a root cronjob?
14 If you look at the PHP constant PATH_SEPARATOR, you will see it being ":" for you. If you break apart your string ".:/usr/share/pear:/usr/share/php" using that character, you will get 3 parts. . (this means the current directory your code is in) /usr/share/pear /usr/share/php Any attempts to include()/require() things, will look in these directories, in this order. It is showing you that in the error message to let you know where it could NOT find the file you were trying to require() For your first require, if that is being included from your index.php, then you dont need the dir stuff, just do... require_once ( 'db/config.php'); Share Improve this answer Follow edited Jul 4, 2020 at 12:27 Binny V A 2,05633 gold badges2020 silver badges2424 bronze badges answered Aug 8, 2013 at 6:38 UberfuzzyUberfuzzy 8,2931111 gold badges4242 silver badges5050 bronze badges 0 Add a comment Β |Β 
I have file structure on EC2 like : but facing some file referencing problem. index.php -db -config.php -cron -cron1.php I have tried file referencing as: `require_once (dirname(__FILE__).'/db/config.php');` `require_once (($_SERVER['DOCUMENT_ROOT']).'/db/config.php');` but cron doesn't run.it gives error in mail as `PHP Warning: require_once(/db/config.php): failed to open stream: No such file or directory in /var/www/html/cron/cron1.php on line 3 Warning: require_once(/db/config.php): failed to open stream: No such file or directory in /var/www/html/cron/cron1.php on line 3 PHP Fatal error: require_once(): Failed opening required '/db/config.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/cron/cron1.php on line 3 Fatal error: require_once(): Failed opening required '/db/config.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/cron/cron1.php on line 3`
what does it mean "(include_path='.:/usr/share/pear:/usr/share/php')"?
Have a look at the documentation: Create a scheduled WebJob using a CRON NCRONTAB expression Timer trigger for Azure Functions The NCRONTAB expression is composed of 6 fields: {second} {minute} {hour} {day} {month} {day of the week}. A CRON expression has only 5, without the seconds. So the first 0 describes the seconds. * * * * * * command to be executed ┬ ┬ ┬ ┬ ┬ ┬ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names) β”‚ β”‚ β”‚ β”‚ └────────── month (1 - 12) β”‚ β”‚ β”‚ └─────────────── day of month (1 - 31) β”‚ | └──────────────────── hour (0 - 23) β”‚ └───────────────────────── min (0 - 59) └────────────────────────────── second(0 - 59)
I used crontab.guru to create a very simple CRON expression with the desired behavior to execute every day at 3:15 (AM) and this is the result: 15 3 * * * Unfortunately for me, in Azure Portal this does not work, but if I add a leading 0 to my expression as such, 0 15 3 * * *, Azure will accept it, while crontab.guru will tell me it is wrong. The specification according to crontab.guru is: minute hour date month weekday. The questions.. From where comes the discrepancy? Is it Microsoft that in their traditional ways have a proprietary implementation with a leading zero? If the standard is minute hour date month weekday, what does the leading zero describe?
Azure WebJob not accepting a valid(?) CRON expression
You should zero-out the second and minute values, and use a step of /3. The cron expression for this is 0 0 */3 * * * Which evaluates to 'At 0 seconds, 0 minutes every 3rd hour'. Your current expression * * */8 * * * would try to run every second of every minute past every 8th hour.
I am trying to run a node-cron job every 3 hours and I am not sure if I am doing it right. Right now I am using: * * */8 * * * Is this correct?
node-cron run job every 3 hours
CronJobs are a good choice. Here's a quick layout that runs 3 nginx pods accepting all traffic. Every minute, a Job curls 1 of the 3 pods (always the same pod). apiVersion: apps/v1beta1 kind: Deployment metadata: name: main labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 --- apiVersion: apps/v1beta1 kind: Deployment metadata: name: singleton labels: app: nginx special: singleton spec: replicas: 1 selector: matchLabels: app: nginx special: singleton template: metadata: labels: app: nginx special: singleton spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 --- kind: Service apiVersion: v1 metadata: name: allpods spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 --- kind: Service apiVersion: v1 metadata: name: singleton spec: selector: special: singleton ports: - protocol: TCP port: 80 targetPort: 80 --- apiVersion: batch/v1beta1 kind: CronJob metadata: name: callout spec: schedule: "*/1 * * * *" concurrencyPolicy: Forbid successfulJobsHistoryLimit: 1 failedJobsHistoryLimit: 1 jobTemplate: spec: template: spec: containers: - name: callout image: buildpack-deps:curl args: - /bin/sh - -ec - curl http://singleton restartPolicy: Never
I have a webapp running in a Docker-container in a Kubernetes cluster. The app has an endpoint I want to be called periodically. The app runs at multiple nodes/pods, and it is important that only one node performs the task initiated by the endpoint. I have looked at Kubernetes Cron Jobs, but have not found any documentation on calling endpoints from a Kubernetes Cron Job. Does anybody have any proposal for a solution of this problem? How do you handle scheduling in a cluster where it is crucial that only one node performs the task?
Call endpoint from Kubernetes Cron Job
There are two possibilities: 2,7,12,17... command */5 .... sleep 120 ; command Write explicit all minutes in crontab Run sleep command before the actual command
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 years ago. Improve this question How could i tell crontab to run every 5 minutes, but starting at the second minute of the hour. In other words, i would like to execute my script when minute % 5 = 2. For example, my script should run at : 08:02 08:07 08:12 08:17 ... Thanks for your help!
Crontab every 5 minutes [closed]
In pathnames, the leading / doesn't mean "home directory"; it always refers to the root of the file system, no matter who you're logged in as. You need to use the actual full, absolute path to the script (e.g. /home/serverpilot/backupS3.sh). If the crontab belongs to the same user whose home directory holds the script, you can use "$HOME"/backupS3.sh and the system will fill in their home directory path for you. Or, even more simply, just use ./backupS3.sh, since cron jobs start with their working directory equal to their owner's home directory. If that doesn't work, then either what you mean by "user directory" is not the same as the POSIX concept of "home directory", or the script is not executable (which you can fix by running the command chmod +x backupS3.sh once). If you're not sure what the full path is, just run the pwd command while you're in the same directory that holds the script, and put the output, followed by a slash, in front of the script name.
I have seen other questions that are similar but I can't find any real information on how to figure out the proper way to run a Bash script via Crontab. The .sh file is located in the user directory (in my case serverpilot). The script is trying to copy the contents of the apps folder and send to my S3 bucket. The script works perfectly when run with sh backupS3.sh from the terminal but no joy via Cron. I've seen people reference PATH variables and the like but no idea where to even begin! /backupS3.sh #!/bin/sh echo 'Started backing to S3' date +'%a %b %e %H:%M:%S %Z %Y' aws s3 sync /apps s3://bucketname date +'%a %b %e %H:%M:%S %Z %Y' echo 'Finished backing to S3' crontab */10 * * * * /backupS3.sh >> backupS3.log Can anyone point me at anything obvious I'm doing wrong? Thanks! EDIT: I've added 2>&1 on to the end of the cron command and now I am getting something in the log file: /bin/sh: 1: /backupS3.sh: not found
How to run a bash script via Cron
The actual problem of your crontab line is not the $() or the backquotes. The problem is the percent sign %. It has a special meaning in crontabs. From the manpage: ... Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. ... If you escape the percent sign with \ it should work as expected: * * * * * echo $(date +\%F) >> /tmp/date.txt or * * * * * echo `date +\%F` >> /tmp/date2.txt both work on my site.
In crontab, can you do something like this? * * * * * echo $( date +%F) >> /path/date.txt
How is % (percent sign) special in crontab?
12 After some research and a lot procrastination I came to the simple conclusion that a ZF-ized cron script should contain all the functionality of you zend framework app - without all the view stuff. I accomplished this by creating a new cronjobfoo.php file in my application directory. Then I took the bare minimum from: -my front controller (index.php) -my bootstrap.php I took out all the view stuff and focused on keeping the environment setup, db setup, autoloader, & registry setup. I had to take a little time to correct the document root variable and remove some of the OO functionality copied from my bootstrap. After that I just coded away.. in my case it was compiling and emailing out nightly reports. It was great to use Zend_Mail. When I was confident that my script was working the way I wanted, I just added it my crontab. good luck! Share Improve this answer Follow answered Jul 16, 2009 at 15:31 ispytoddispytodd 14122 silver badges66 bronze badges Add a comment Β |Β 
I am trying to write a cronjob controller, so I can call one website and have all modules cronjob.php executed. Now my problem is how do I do that? Would curl be an option, so I also can count the errors and successes? [Update] I guess I have not explained it enough. What I want to do is have one file which I can call like from http://server/cronjob and then make it execute every /application/modules/*/controller/CronjobController.php or have another way of doing it so all the cronjobs aren't at one place but at the same place the module is located. This would offer me the advantage, that if a module does not exist it does not try to run its cronjob. Now my question is how would you execute all the modules CronjobController or would you do it a completly different way so it still stays modular? And I want to be able to giveout how many cronjobs ran successfully and how many didn't
Create cronjob with Zend Framework
Just looking at it, I think you need to: parse the chron spec to five arrays containing acceptable values for each field; parse 'now' to a value for each field; in order of minute, hour, {day-of-month OR day-of-week}, month-of year: find the lowest array value that matches or exceeds the current value, correcting for carry. I don't know how to handle day-of-week and day-of-month simultaneously; I am sure there is a way, but on the other hand I don't think I've ever seen a spec that actually specified both. I think it would be sufficient to write a handler for either and throw an error if you receive both. Edit: apparently if day-of-week and day-of-month are both specified, it is supposed to fire on both - ie if the rule is '15th, Wednesday' it will fire on every 15th and every Wednesday. The croniter package does what you want: import croniter import datetime now = datetime.datetime.now() sched = '1 15 1,15 * *' # at 3:01pm on the 1st and 15th of every month cron = croniter.croniter(sched, now) for i in range(4): nextdate = cron.get_next(datetime.datetime) print nextdate prints 2011-01-15 15:01:00 2011-02-01 15:01:00 2011-02-15 15:01:00 2011-03-01 15:01:00 although it would be nice if it were written as an actual iterator. Maybe I've got my next project ;-)
What's an efficient way to calculate the next run time of an event given the current time and a cron spec? I'm looking for something other than "loop through every minute checking if it matches spec". Examples of specs might be: Every month, on the 1st and 15 at 15:01 At 10,20,30,40,50 mins past the hour every hour Python code would be lovely but psuedo code or high level description would also be appreciated. [Update] Assume the spec is already parsed and is in some reasonable format.
Calculate next scheduled time based on cron spec
its simple SHOW EVENTS lists all of the events in the current schema To see events for a specific schema, use the FROM clause. For example, to see events for the test schema, use the following statement: SHOW EVENTS FROM test;
I have a MySQL database. I am running two MySQL EVENTs. I need to get rid of one. I don't remember it's name. What do I do?
Show all MySQL events that are running on my database?
The -s file test will tell you if a file exists and has size greater than zero. ./prog >/dev/null 2>some/file ; if [ -s some/file ] ; then mail < some/file ; fi
I have some python scripts that run on a daily basis in cron. How can I have cron send me an email ONLY WHEN THERE IS STDERR OUTPUT from my script? I want to be able to mail multiple recipients, and set the subject line individually for each cron entry. I tried this: ./prog > /dev/null | mail . . . but it didn't work -- I still receive blank emails when there is no STDERR. Do I need to do this in the script itself? Sorry if this seems basic, I have googled a lot but can't seem to find this answered succintly.
Cron send email with STDERR but NOT STDOUT?
It is a question on cron. First is add a SHEBANG line on top of your python script. #!/usr/bin/env python Make your script executable with chmod +x And do a crontab -e and add 0 0 */2 * * /path/to/your/pythonscript.py
It might be very simple question, but how could I run a python script on my fedora dist every 2 days? Thanks Antonis
running a python script with cron
My Problem was, that cron had no access to the Disk, so it couldn't run my script. I had to give Full Disk Access for /usr/sbin/cron See this blog post: https://blog.bejarano.io/fixing-cron-jobs-in-mojave/
I just have started to use crontab and have some problems with it. I have already read some posts about how to use it on macOS, but it still not working. So, I write crontab -e, then edit it to */1 * * * * cliclick -w 1 m:3,3 (for example) - which mean repeat click in x=3;y=3 every 1 min. And nothing has changed. But, when I use just this command from the terminal everything is ok. I have already tried to create a script.sh file, and the same situation: from hand-command it works, and from crontab isn't. Maybe, I do something wrong? UPDATE: Full disk access crontab has. UPDATE2: I tried do it again on the BigSur. First of all I use a more simple command like echo: * * * * * echo 'test' >> /*/Desktop/text.txt And it works well. After that, I write my own script.sh echo '2test' >> /Users/***/Desktop/t.txt /usr/local/bin/cliclick -w 1 m:1,3 cliclick -w 1 m:55,44 And it the cliclick not working, as the other bin files located in /usr/local/bin/ (cliclick located in this path) Note, that if I execute ./script.sh then cliclick works fine in both cases. I thoroughly googled and found that run cliclick (and other) is NOT possible though crontab: https://github.com/BlueM/cliclick/issues/103
Crontab is not running local/bin/ script. Catalina, BigSur
38 in cron jobs, here is how you should pass the argument /usr/bin/php -q /home/**/public_html/scores.php date=12/05/2009 *take note there is no "?" Share Improve this answer Follow answered Dec 7, 2011 at 17:39 DennisDennis 3,60844 gold badges2828 silver badges4141 bronze badges 0 Add a comment Β |Β 
Is it correct to use the following command in a cron job: /usr/bin/php -q /home/**/public_html/scores.php?date=12/05/2009 I haven't found any supportive article / material to answer it, hence i am putting forth this question to the community. So the question is is there a way for me to include a variable in a cron job calling a PHP script? Thanks
Cron Jobs calling a PHP script with variables
At the end of the file, add a new blank line, and reinstall crontab crontab.txt
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 7 years ago. Improve this question When I try installing my Cron job I get the following error: "crontab.txt":8: premature EOF errors in crontab file, can't install
Can't install CRON job [closed]
Start by typing at a command line: whereis php Do this as the user that the cron job will be run under. This will show you the path to your executable. You can then use that path (if it's not already in your PATH variable) in your cron entry: 5 * * * * /your/path/to/php /var/www/some/path/script.php Edit: you may need to install the php5-cli (Ubuntu package name) package if all you have is the Apache PHP module installed. This will give you the binary executable that you can run from a command line.
I'm trying to run a php-script on a scheduled basis. So I'd thought crontab was a good idea. The server I'm using is on Linux which I'm not that familiar with. So the problem I'm having is, I don't know how make the script executable from php. I need to reference the script, or put it into a folder that can run php from the command line. So I don't know what path to give my crontab, for example: 5 * * * * var/www/some/path/script.php I found some vague information about this php executable being found in /usr/bin/php But I can't find any php file in there, maybe I don't have it installed? My php5 and apache installation is in: /etc/php5 So my question becomes, is there anyway to execute a php-script with crontab in any other folder, or do I just lack the php executable in usr/bin/php?
Executing php with crontab
20 $_SERVER['HTTP_HOST'] is not populated when running it from a cronjob, the file is not accessed via HTTP. You will either have to hardcode the Host or pass it via a command line argument and access it via the $_SERVER['argv'] array. Share Improve this answer Follow edited May 26, 2015 at 22:34 answered Feb 3, 2012 at 12:14 TimWollaTimWolla 32.1k88 gold badges6565 silver badges9797 bronze badges 2 1 Good answer. CLI scripts have $argv and $argc globals that you can access, so there is no need to use $_SERVER. – Neil Aitken Feb 3, 2012 at 12:16 2 $argv is not available in functions without the global-keyword. $_SERVER is superglobal. – TimWolla Feb 3, 2012 at 12:18 Add a comment Β |Β 
I want to run a cron job. My application is developed in PHP and Mysql. In browser if i use $_SERVER[HTTP_HOST] in coding, it works fine. But if I use the same thing in cron job it is giving errors. Can any body give suggestion to fix this?
Cron Job $_SERVER issue
recently I had sort of problems to run a cron job on a php script on localhost (WAMP server) in windows 7, when I was on a test to chronically fetch some links from www out there. By the way I am sharing this for anyone that is on the same thing. You will need a shellscript to run chronically, using Windows Task Scheduler. Also you will need a batch script (script.bat) to call the php.exe and run your php script (here called as my_process.php) shellscript.vbs Set WinScriptHost = CreateObject("WScript.Shell") WinScriptHost.Run Chr(34) & "C:\path\to\script\script.bat" & Chr(34), 0 Set WinScriptHost = Nothing script.bat "C:\wamp\bin\php\php5.4.12\php.exe" -f "C:\wamp\www\website\my_process.php" Now, we are ready to set the Windows Task Scheduler to run shellscript.vbs at the required time interval: Open Task Scheduler from windows Start menu Go to Action menu and hit Create Task... in General tab, fill the Name and Description fields as you want in Triggers tab, hit New button. from Begin the Task dropdown, select On a schedule and choose Daily from Advanced settings section, select Repeat task every as you want and set for a duration on Indefinitely. on Actions tab, from Action dropdown, select Start a program. on the Program\script box, enter path to shellscript.vbs like C:\path\to\shellscript.vbs. leave Add argumentts (optional) section empty. in Start in (optional) box, enter parent directory of shellscript.vbs like C:\path\to\. Hit upvote on this tutorial :) Have fun.
I have a php script and want to run it on an schedule. I am using local web server on windows (WAMP server) and need a way to run my_script.php every 10 min. How to run a cron job on a PHP script, on localhost in windows?
Run Cron Job on PHP Script, on localhost in Windows
21 Yes, just add it to the root users' crontab; run the crontab -e command. The places cron stores its files can be a little bizzare, so use the crontab -e command which will make sure it's in the right place, and I believe it checks the syntax. Share Improve this answer Follow edited Jan 10, 2014 at 17:55 Peter Mortensen 31k2222 gold badges108108 silver badges132132 bronze badges answered Jun 18, 2009 at 22:19 whatsisnamewhatsisname 5,97022 gold badges2121 silver badges2727 bronze badges 2 I've listed all crontab files,which do you mean I should modify? – omg Jun 18, 2009 at 22:27 3 Instead of directly modifying a crontab file yourself, whatsisname is suggesting you use the "crontab -e" command, which will edit the correct crontab. – ephemient Jun 18, 2009 at 23:01 Add a comment Β |Β 
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 10 years ago. Improve this question I need that Bash file to run periodically, and it must be as root. Is that possible? [root@file nutch-0.9]# locate crontab /etc/crontab /etc/sysconfig/crontab /usr/bin/crontab /usr/share/man/man1/crontab.1.gz /usr/share/man/man1p/crontab.1p.gz /usr/share/man/man5/crontab.5.gz /usr/share/vim/vim71/syntax/crontab.vim [root@file nutch-0.9]#
Is it possible to make a Bash file run as root in crontab? [closed]
I have always had good luck using File::NFSLock to get an exclusive lock on the script itself. use Fcntl qw(LOCK_EX LOCK_NB); use File::NFSLock; # Try to get an exclusive lock on myself. my $lock = File::NFSLock->new($0, LOCK_EX|LOCK_NB); die "$0 is already running!\n" unless $lock; This is sort of the same as the other lock file suggestions, except I don't have to do anything except attempt to get the lock.
I need to run Perl script by cron periodically (~every 3-5 minutes). I want to ensure that only one Perl script instance will be running in a time, so next cycle won't start until the previous one is finished. Could/Should that be achieved by some built-in functionality of cron, Perl or I need to handle it at script level? I am quite new to Perl and cron, so help and general recommendations are appreciated.
Running only one Perl script instance by cron
0 10/2 * * * /directory/job.sh would do it. 0 10-22/2 * * * /directory/job.sh would do it and be more explicit. 0 10,12,14,16,18,20,22 * * * /directory/job.sh would do it, too.
I need my crontab to execute every 2 hours starting at 10am and the last one running at 10pm. I currently have 0 */2 * * * /directory/job.sh How do I block out the hours I don't want? Thanks!
How to make crontab execute every 2 hours between 10am and 10pm?
This sample was taken at http://php.net/flock and changed a little and this is a correct way to do what you want: $fp = fopen("/path/to/lock/file", "w+"); if (flock($fp, LOCK_EX | LOCK_NB)) { // do an exclusive lock // do the work flock($fp, LOCK_UN); // release the lock } else { echo "Couldn't get the lock!"; } fclose($fp); Do not use locations such as /tmp or /var/tmp as they could be cleaned up at any time by your system, thus messing with your lock as per the docs: Programs must not assume that any files or directories in /tmp are preserved between invocations of the program. https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s18.html https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html Do use a location that is under your control. Credits: MichaΓ«l Perrin - for proposing to use w+ instead of r+
I'm trying to find a safe way to prevent a cron job collision (ie. prevent it from running if another instance is already running). Some options I've found recommend using a lock on a file. Is that really a safe option? What would happen if the script dies for example? Will the lock remain? Are there other ways of doing this?
PHP - Preventing collision in Cron - File lock safe?
you can try the following solution as well: chmod +x post.php chmod +x bash.sh echo "* * * * * /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1" >> cronjob chmod +x cronjob /etc/init.d/crond start #redhat based servers like centos /etc/init.d/cron start #debian based servers like ubuntu crontab cronjob
How to run a cron with bash script here.What i did as follows and here with errors.I want to know how to do that in ubuntu.I was struck with it now bash.sh file #!/bin/bash cd /var/www/Controller /usr/bin/php post.php In crontab -e * * * * * /home/samitha/bash.sh >> /home/samitha/log/cron.log 2>&1 But now i getting following error /bin/sh: 1: /home/samitha/bash.sh: Permission denied How will i fix it ? what i did wrong ?
Permission denied with bash.sh to run cron
i think i solve my own question. My php takes some time to load, i guess wget retries or time out after some default specified time. I solved it by using /usr/bin/php
I've a php script which runs from webservice and insert to DB. crontab -e ......other cron tasks above....... ... .. .. # Run test script.php at 1610 10 16 * * * /usr/bin/wget -q -O /home/username/my_cronjobs/logs/cron_adhoc http://localhost/project/script.php Apparently, at 16:10, this script is run twice! 16:10:01 and 16:25:02 Is it something wrong and gotta do with using wget?? Or did i set the schedule on cron job wrongly? When i run http://localhost/project/script.php from browser, it will only run once.. Any idea regarding this problem ? I've tested, there are no other users running the same job... I suspect the way wget works. As my script needs at least 20mins to complete without sending back a response (it is pulling alot of data from webservicces and save to db) .. suspect there's a time out or retry of wget by default causing this problem.
crontab with wget - why is it running twice?
The error message suggests that Rails isn't defined. i.e the framework isn't loaded when you're asking the question what environment is rails running with. In fact from looking at the code for Whenever it looks like rails isn't a requirement for it (i.e. You can install and run Whenever without rails even being installed on your system). Hence there's no way for Whenever to look at your rails environment (as far as i can tell)
This question will probably only make sense if you know about the whenever gem for creating cron jobs. For my app, I want to use whenever in all the environments, including testing and development. My schedule.rb looks like this: set :output, { :error => "#{path}/log/error.log", :standard => "#{path}/log/cron.log" } set :environment, Rails.env.to_sym every 5.minutes do rake 'db:activity:synchronize' end but it fails on Rails.env.to_sym (and the same stands for RAILS_ENV): /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval': uninitialized constant Whenever::JobList::Rails (NameError) from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `initialize' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever.rb:15:in `new' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever.rb:15:in `cron' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/command_line.rb:41:in `run' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/command_line.rb:8:in `execute' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/bin/whenever:38:in `<top (required)>' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/bin/whenever:19:in `load' from /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/bin/whenever:19:in `<main>' So, my question basically boils down to: How do I access the current environment, or What should I do to use whenever in all the environments?
How to detect Rails environment inside whenever
This problem was fixed. The real issue was in the PHP script I used. Earlier in the stream_context_set_option I I did not include the full path to the ck.pem file . After giving the full path there was no error. Below is the code I am using right now. $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', '/Users/Development/Dev/ck.pem'); Some others who have had this problem and their discussions are Apple Forum Question 1 Apple Forum Question 2
I have implemented a sample push notification service for my App. Right now I test in a sandbox environment. I get notifications when I manually call the PHP script to push notifications through APN. When I write a scheduler using crontab to automate the delivery of notifications I dont get the notifications. The error I get as a mail is: PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in /Users/aspire/Desktop/SimplePush/simplepush.php on line 21 PHP Warning: stream_socket_client(): Failed to enable crypto in /Users/aspire/Desktop/SimplePush/simplepush.php on line 21 PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /Users/aspire/Desktop/SimplePush/simplepush.php on line 21 Failed to connect: 0 Can someone explain what the problem could be?
iOS push notification does not work when using crontab scheduler
It is possible to create multiple triggers for one scheduled task. If you create 59 identical triggers with an offset of 1 second to each other, and schedule the task itself to run every minute, you end up the scheduled task to run every second. You could create those 59 triggers manually using the GUI. However, a much quicker way to create so many triggers is to create a task with one or two triggers, export it to a text file, duplicate the according lines, change the start offsets accordingly, and then re-import the file.
I'm looking for an open source/free task scheduler for Windows 7 (development machine) that will allow me to schedule tasks (HTTP requests to a web service) to run every x seconds. I've tried a couple of Cron clones and windows own Task Scheduler but neither seem to allow tasks to run at intervals less than 60 seconds. Am I missing something? I don't want to have to go and write any custom scripts either if possible.
Windows task scheduler to execute tasks in seconds
Since you seem to have superuser rights anyway, you could put those commands into the crontab of the postgres user like so: sudo su postgres crontab -e and then put the pg_dump/vacuumdb commands there.
I can run commands like vacuumdb, pg_dump, and psql just fine in a script if I preface them like so: /usr/bin/sudo -u postgres /usr/bin/pg_dump -Fc mydatabase > /opt/postgresql/prevac.gz /usr/bin/sudo -u postgres /usr/bin/vacuumdb --analyze mydatabase /usr/bin/sudo -u postgres /usr/bin/pg_dump -Fc mydatabase > /opt/postgresql/postvac.gz SCHEMA_BACKUP="/opt/postgresql/$(date +%w).db.schema" sudo -u postgres /usr/bin/pg_dump -C -s mydatabase > $SCHEMA_BACKUP These run at command line on Redhat when I am sudo to root and then as you see in the commands above I do a sudo -u to postgres. But when I try to kick this off from cron, I get zero bytes in all the files -- meaning it didn't run properly. And I don't get a clue in the logs that I can see. My /etc/crontab file has this entry at the bottom 00 23 * * * root /etc/db_backup.cron And yes, /etc/db_backup.cron is chmod ug+x, owned by root, and the top of the file says "#!/bin/bash" (minus doublequotes). Anyone know what gives?
How Do I Backup My PostgreSQL Database with Cron?
I've successfully used NCrontab for exactly this purpose. using something like var schedule = CrontabSchedule.Parse("15 35 * * *"); return schedule.GetNextOccurrence(DateTime.Now);
I have crontab-like scheduler. Time definition "MM HH WD MD M": MM- minutes HH- hours WD- days of week MD - days of month M - months WD, MD and M allow multiple entries and each of params can be null, for example: ^ ^ 0, 1 ^ ^ means exucution every minute, every hour, at sunday and mondey, every day<br> 35 15 ^ ^ ^ execution every day at 15.35<br> The problem is how to calculate next run time, if you know last execution date. I know how to do this using loop (just add 1 minute until it fits the condition), but there must be better way.
Calculate Cron Next Run Time in C#
In case you'd set it up in a crontab, this works: */1 * * * * /usr/bin/wget -O /dev/null http://example.com/cron.php
I have a file in mysite.com/url1/url2/cronjob.php which has to be run every minute. I try every combination, but can't succeed. What should I run in command line? Thank you.
Cronjob every minute
The most evident problem with trying to launch a browser from cron is that even if you have X running on your machine, the DISPLAY environment variable is not set for processes running from your crontab so launching a browser from there will fail. Solutions range from the trivial to the super sophisticated. A trivial solution would be to accept that your script won't run if there is no X running and manually set DISPLAY to :0, which is the default display number for the default X server that Ubuntu starts. For instance, if I put this command in the command column of a crontab line, Chrome starts without issue: DISPLAY=:0 google-chrome The complete line in the a user-specific crontab file would be something like: 0 * * * * DISPLAY=:0 google-chrome If you want to run a python script that starts chrome through selenium, the line would instead look like: 0 * * * * DISPLAY=:0 python my_script.py The command string is just sent as-is to the shell so in the last example the string DISPLAY0 would be just passed to the shell. It is common shell syntax to interpret a variable assignment given immediately at the start of the command as setting an environment variable. (It is certainly the case for DISPLAY1 and DISPLAY2, one of which is likely to be the default shell in most installations.) So the command that the shell interprets sets the environment variable DISPLAY3 to the value DISPLAY4 and then runs DISPLAY5. Since DISPLAY6 inherits its environment from the shell that started it, the variable DISPLAY7 is DISPLAY8 for it too. Setting DISPLAY9 like I show above sets the variable only for the command that follows. It is also possible to set crontab0 to crontab1 for all commands executed by the crontab. For instance in the following user-specific crontab: crontab2 the line crontab3 sets the environment variable crontab4 both for the execution of crontab5 and crontab6
I have a python script that calls chrome via selenium with the next line. ff = webdriver.Chrome('/home/user01/webScraping/CollectAndGo/chromedriver') The python script is called from a shell script. python /home/user01/webScraping/CollectAndGo/cgcom.py > /home/user01/webScraping/CollectAndGo/cgcom.log 2>&1 When I run the script from the terminal or just executing the .sh file it works perfectly but when I schedule a crontab job it fail with the next error. raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: u'unknown error: Chrome failed to start: exited abnormally\n (Driver info: chromedriver=2.9.248304,platform=Linux 3.5.0-36-generic x86_64)' The error is related to the first line of code of this question. Does anybody know why this could be happening?
run selenium with crontab (python)
In Python, to delete all cron jobs, change the cron.yaml file to just contain: cron: In Java, to delete all cron jobs, change the cron.xml file to just contain: <?xml version="1.0" encoding="UTF-8"?> <cronentries/>
I registered a cron job in the google appengine. It runs fine. Since I deleted the whole content of the app, I want this job to not run anymore. I don't know how to do it.
How to deregister a CRON job in AppEngine?