Questions tagged [cron]

Cron is a time-based job scheduler running as a daemon process in Unix-like computer operating systems. Questions about configuring cron for systems or administration are OFF TOPIC.

cron
Filter by
Sorted by
Tagged with
997 votes
25 answers
1.1m views

How do I list all cron jobs for all users?

Is there a command or an existing script that will let me view all of a *NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as /etc/crontab, and ...
yukondude's user avatar
  • 24.3k
589 votes
12 answers
848k views

Restarting cron after changing crontab file? [closed]

Do I have to restart cron after changing the crontable file?
bArmageddon's user avatar
  • 8,298
542 votes
22 answers
472k views

How to create a cron job using Bash automatically without the interactive editor?

Does crontab have an argument for creating cron jobs without using the editor (crontab -e)? If so, what would be the code to create a cron job from a Bash script?
Raúl Roa's user avatar
  • 12.2k
532 votes
31 answers
725k views

How to run a cron job inside a docker container?

I am trying to run a cronjob inside a docker container that invokes a shell script. How can I do this?
C Heyer's user avatar
  • 5,323
491 votes
19 answers
503k views

How to pass in password to pg_dump?

I'm trying to create a cronjob to back up my database every night before something catastrophic happens. It looks like this command should meet my needs: 0 3 * * * pg_dump dbname | gzip > ~/backup/...
mpen's user avatar
  • 278k
477 votes
9 answers
445k views

How do I get a Cron like scheduler in Python?

I'm looking for a library in Python which will provide at and cron like functionality. I'd quite like have a pure Python solution, rather than relying on tools installed on the box; this way I run on ...
jamesh's user avatar
  • 20k
447 votes
20 answers
969k views

Running a cron every 30 seconds

Ok so I have a cron that I need to run every 30 seconds. Here is what I have: */30 * * * * /bin/bash -l -c 'cd /srv/last_song/releases/20120308133159 && script/rails runner -e production '\''...
Matt Elhotiby's user avatar
383 votes
7 answers
683k views

Running a cron job at 2:30 AM everyday

How to configure a cron job to run every night at 2:30? I know how to make it run at 2, but not 2:30.
user1856596's user avatar
  • 7,127
377 votes
21 answers
436k views

Where can I set environment variables that crontab will use?

I have a crontab running every hour. The user running it has environment variabless in the .bash_profile that work when the user runs the job from the terminal, however, obviously these don't get ...
James's user avatar
  • 15.3k
375 votes
10 answers
1.0m views

How do I schedule jobs in Jenkins?

I added a new job in Jenkins, which I want to schedule periodically. From Configure job, I am checking the "Build Periodically" checkbox and in the Schedule text field added the expression: 15 13 *...
Sangram Anand's user avatar
347 votes
3 answers
152k views

Run Cron job every N minutes plus offset

*/20 * * * * Ensures it runs every 20 minutes, I'd like to run a task every 20 minutes, starting at 5 past the hour, is this possible with Cron? Would it be: 5/20 * * * * ?
AJP's user avatar
  • 27.4k
335 votes
11 answers
602k views

How to run crontab job every week on Sunday

I'm trying to figure out how to run a crontab job every week on Sunday. I think the following should work, but I'm not sure if I understand correctly. Is the following correct? 5 8 * * 6
dev_fight's user avatar
  • 3,405
324 votes
20 answers
180k views

Cron and virtualenv

I am trying to run a Django management command from cron. I am using virtualenv to keep my project sandboxed. I have seen examples here and elsewhere that show running management commands from within ...
John-Scott's user avatar
  • 3,273
321 votes
2 answers
692k views

Using crontab to execute script every minute and another every 24 hours [closed]

I need a crontab syntax which should execute a specific PHP script /var/www/html/a.php every minute. The execution on every minute must start at 00:00. The other task which must execute a script at 00:...
Michael 's user avatar
  • 6,387
316 votes
12 answers
321k views

How do I write a bash script to restart a process if it dies?

I have a python script that'll be checking a queue and performing an action on each item: # checkqueue.py while True: check_queue() do_something() How do I write a bash script that will check if ...
Tom's user avatar
  • 43.7k
312 votes
10 answers
423k views

How to log cron jobs?

I want to know how I can see exactly what the cron jobs are doing on each execution. Where are the log files located? Or can I send the output to my email? I have set the email address to send the log ...
Adrian M.'s user avatar
  • 7,353
306 votes
21 answers
121k views

A cron job for rails: best practices?

What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes.
jes5199's user avatar
  • 18.6k
303 votes
6 answers
578k views

Spring cron expression for every day 1:01:am

I'm trying to have my code execute on a fixed schedule, based on a Spring cron expression. I would like the code to be executed every day at 1:01:am. I tried the following expression, but this didn't ...
d-man's user avatar
  • 57.8k
297 votes
3 answers
375k views

Crontab Day of the Week syntax

In crontab does the Day of the Week field run from 0 - 6 or 1 -7? I am seeing conflicting information on this. wikipedia states 0-6 and other sites I have seen are 1-7. Also what would be the ...
Marty Wallace's user avatar
297 votes
15 answers
341k views

What is the Windows version of cron? [closed]

A Google search turned up software that performs the same functions as cron, but nothing built into Windows. I'm running Windows XP Professional, but advice for any version of Windows would be ...
Thomas Owens's user avatar
294 votes
6 answers
491k views

How to run cron job every 2 hours? [closed]

How can I write a Crontab that will run my /home/username/test.sh script every 2 hours?
Vignesh's user avatar
  • 8,429
279 votes
14 answers
106k views

How to simulate the environment cron executes a script with?

I normally have several problems with how cron executes scripts as they normally don't have my environment setup. Is there a way to invoke bash(?) in the same way cron does so I could test scripts ...
Jorge Vargas's user avatar
  • 6,832
276 votes
6 answers
390k views

How would I get a cron job to run every 30 minutes?

I'm looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but it doesn't seem to run on 0. */30 * * * ...
Darryl Hein's user avatar
261 votes
11 answers
314k views

Test a weekly cron job [closed]

I have a #!/bin/bash file in cron.week directory. Is there a way to test if it works? Can't wait 1 week I am on Debian 6 with root
dynamic's user avatar
  • 47.5k
250 votes
2 answers
150k views

Crontab - Run in directory

I would like to set a job to run daily in the root crontab. But I would like it to execute it from a particular directory so it can find all the files it needs, since the application has a bunch of ...
user333746's user avatar
  • 2,675
240 votes
5 answers
486k views

How to run cron once, daily at 10pm [closed]

I had entered: * 22 * * * test > /dev/null However, I am being notified via email that this is running every minute. I am confused I guess because I thought this was correct for what I am wanting....
user avatar
233 votes
16 answers
235k views

How do I create a crontab through a script

I need to add a cron job thru a script I run to set up a server. I am currently using Ubuntu. I can use crontab -e but that will open an editor to edit the current crontab. I want to do this ...
stocked's user avatar
  • 2,979
191 votes
5 answers
290k views

How to specify in crontab by what user to run script? [closed]

I have few crontab jobs that run under root, but that gives me some problems. For example all folders created in process of that cron job are under user root and group root. How can i make it to run ...
arma's user avatar
  • 4,114
184 votes
27 answers
579k views

What is the curl error 52 "empty reply from server"?

I have a cron job setup on one server to run a backup script in PHP that is hosted on another server. The command I've been using is curl -sS http://www.example.com/backup.php Lately I've been ...
Paul Sheldrake's user avatar
180 votes
16 answers
159k views

Run cron job only if it isn't already running

I'm trying to set up a cron job as a sort of watchdog for a daemon that I've created. If the daemon errors out and fails, I want the cron job to periodically restart it... I'm not sure how possible ...
LorenVS's user avatar
  • 12.7k
174 votes
15 answers
236k views

How to get CRON to call in the correct PATHs

I'm trying to get cron to call in the correct PATHs. When I run a Python script from shell the script runs fine as it uses the PATHs set in bashrc but when I use cron all the PATHs are not used from ...
chrisg's user avatar
  • 40.8k
171 votes
10 answers
198k views

How to automatically remove completed Kubernetes Jobs created by a CronJob?

Is there a way to automatically remove completed Jobs besides making a CronJob to clean up completed Jobs? The K8s Job Documentation states that the intended behavior of completed Jobs is for them to ...
Josh Newman's user avatar
  • 1,735
168 votes
6 answers
254k views

How to write a cron that will run a script every day at midnight?

I have heard crontab is a good choice, but how do I write the line and where do I put it on the server?
Matt Elhotiby's user avatar
162 votes
12 answers
327k views

How to run a script in the background even after I logout SSH?

I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH?
zihaoyu's user avatar
  • 5,571
160 votes
10 answers
244k views

How to schedule a function to run every hour on Flask?

I have a Flask web hosting with no access to cron command. How can I execute some Python function every hour?
RomaValcer's user avatar
  • 2,866
157 votes
22 answers
281k views

CRON job to run on the last day of the month

I need to create a CRON job that will run on the last day of every month. I will create it using cPanel. Any help is appreciated. Thanks
Utku Dalmaz's user avatar
  • 9,940
155 votes
21 answers
93k views

How can I programmatically create a new cron job?

I want to be able to programatically add a new cron job, what is the best way to do this? From my research, it seems I could dump the current crontab and then append a new one, piping that back into ...
davidmytton's user avatar
149 votes
2 answers
134k views

Spring cron vs normal cron?

I'm trying to get a cron job working within a legacy Java/Spring/Hibernate project, so I decided to use the spring scheduler. I want myTask.doStuff to run at 12:00 on the first Sunday of every month. ...
Paul's user avatar
  • 3,452
148 votes
7 answers
212k views

Running a cron job on Linux every six hours

How can I run command every six hours every day? I tried the following, but it did not work: /6 * * * * * mycommand
Gandalf StormCrow's user avatar
144 votes
14 answers
158k views

Cron jobs and random times, within given hours

I need the ability to run a PHP script 20 times a day at completely random times. I also want it to run only between 9am - 11pm. I'm familiar with creating cron jobs in linux.
floatleft's user avatar
  • 6,403
142 votes
11 answers
187k views

Cron job every three days

Is it possible to run a cronjob every three days? Or maybe 10 times/month.
tmartin314's user avatar
  • 4,121
141 votes
6 answers
167k views

I need a Nodejs scheduler that allows for tasks at different intervals [closed]

I am looking for a node job schedule that will allow me to schedule a number of tasks at different intervals. For instance, call function A every 30 seconds call function B every 60 seconds call ...
user379468's user avatar
  • 3,999
138 votes
7 answers
139k views

Disabling cronjob in Kubernetes

I have scheduled an application to run as a CronJob in Kubernetes. When there is a code change, I'm also changing the image of the CronJob. I'm looking for an option where I can disable the currently ...
Jasmitha Meka's user avatar
130 votes
8 answers
330k views

Setting up a cron job in Windows

I have to download a file from an SFTP server everyday. I have the program which retrieves the file from the server but I was thinking of setting up a cron job (or anything similar) to automate that. ...
mona's user avatar
  • 6,199
130 votes
7 answers
128k views

A cron job that will never execute

Is there any way to create a cron expression for not running the job at all? I though of using this expression : 0 0 0 1 1 ? 3099 ...which will practically do the job as it will run on year 3099, ...
Madhu CM's user avatar
  • 2,436
124 votes
7 answers
208k views

How to run a cronjob every X minutes?

I'm running a PHP script in a cronjob and I want to send emails every 5 minutes My current (crontab) cronjob: 10 * * * * /usr/bin/php /mydomain.in/cromail.php > /dev/null 2>&1 The ...
Savan Paun's user avatar
  • 1,733
120 votes
7 answers
94k views

How do I set a task to run every so often?

How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.
stalepretzel's user avatar
  • 15.8k
120 votes
12 answers
152k views

Use PHP to create, edit and delete crontab jobs?

Is it possible to use PHP to create, edit and delete crontab jobs? I know how to list the current crontab jobs of the Apache user: $output = shell_exec('crontab -l'); echo $output; But how to add a ...
datasn.io's user avatar
  • 12.7k
119 votes
5 answers
329k views

mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab

I am having problems with getting a crontab to work. I want to automate a MySQL database backup. The setup: Debian GNU/Linux 7.3 (wheezy) MySQL Server version: 5.5.33-0+wheezy1(Debian) directories ...
user3397547's user avatar
  • 1,193

1
2 3 4 5
396