Questions tagged [cron]
cron is a task scheduler based on clock time that runs on Linux-based machines.
912
questions
101
votes
8
answers
183k
views
How can I view results of my cron jobs?
I see so many guides on how to run crontab, but what I need right now is to learn how to
Find log files about cron jobs
Configure what gets logged
84
votes
13
answers
194k
views
How to make WSL run services at startup
After searching this site and various Q, it is clear that services and systemd is not available for WSL. I need to run a program in WSL every time I start my PC so I read this page on how to use ...
83
votes
11
answers
353k
views
How to stop a currently running cron job?
How can I stop a cron job which is currently running?
81
votes
4
answers
219k
views
How to run a cron job as a specific user?
I would like to run a cron job as a specific user on my machine. How may I specify the user for a cron job to run as?.
The cron jobs will be running on a server (running on Ubuntu 10.0.4). The 'users'...
80
votes
11
answers
140k
views
How can I get a script to run every day on Mac OS X?
Cron? Launchd? iCal??
If so, how?
74
votes
7
answers
184k
views
Run a command every week with Cron?
Simple question- what would a crontab entry look like for a command I want to run every week on Saturday at 8:05 AM?
72
votes
2
answers
123k
views
Set a cron every certain hours between certain hours
How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?
59
votes
19
answers
129k
views
Run a cron job on the first Monday of every month?
I'd like to run a job from cron at 8.30 on the first Monday of every month. The cron Wikipedia page says
While normally the job is executed when the time/date specification fields all match
...
57
votes
2
answers
62k
views
Difference between /etc/crontab and "crontab -e"
What is the difference between the crontab located in /etc/crontab and the crontab that can be edited using crontab -e?
51
votes
1
answer
94k
views
what is run-parts in /etc/crontab, and how do I use it
I have been digging through my Linux system. To try and understand how it all works
In the /etc/crontab file. I see the following
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * ...
46
votes
4
answers
43k
views
Log of cron actions on OS X
Does the cron which comes with OS X log its actions anywhere?
I'm not looking for output of any particular cron job, but rather log of what cron is doing. On a couple linux machines I've checked, ...
40
votes
3
answers
1k
views
What is the point of system-autodeath?
In a previous question I found a "system autodeath cron job" which would shut down my default network route daily.
As I have never heard of such a thing before, I would like to know what it exactly ...
39
votes
9
answers
23k
views
Error adding cronjobs in Mac OS X Lion
Until now, I have never attempted adding a crontask on my Mac. To my surprise, it threw an error..
[hayek@mac:/www/] 02:33:22 PM: crontab -e ...
36
votes
2
answers
53k
views
Why doesn't my cron.d per minute job run?
I have thrown a bunch of darts trying to get a python script of mine to execute every minute. So I thought I'd simplify it to just do the "simplest thing that could could possibly work" once per ...
35
votes
5
answers
64k
views
How do I run a launchd command as root
I have the following launchctl command as a .plist file. It's loaded and set to run once a day but, it needs to run as root and I'm not sure how to verify this.
Also, this cron job basically CDs ...
33
votes
5
answers
43k
views
crontab to wake osx from sleep
I have a crontab which will launch a certain program early in the morning (after I have gone to sleep) and close it again later in the morning (before I wake up). But my iMac will not execute the ...
24
votes
3
answers
46k
views
How to use @reboot in /etc/cron.d
I am migrating individual user's crontabs to /etc/cron.d, as that would allow proper backup, restore and versioning.
So far, as I understand the only difference between user's crontabs and the etc ...
23
votes
2
answers
32k
views
How do I setup a cron job on OS X to run a curl command at a specific time every day?
I have a CURL command I want to run every day at say 3am, but I am not sure about how to set that up and the guides are all weird.
Assume I have a lot of terminal/bash experience, but I have never ...
21
votes
2
answers
67k
views
linux: how to run a command in a given directory
I simply want to just run a command (actually its a shell script) from a given directory as a cron job. How can I run it so that it is set to a given directory without using cd.
21
votes
4
answers
14k
views
How did I wipe out all my cron jobs?
I have accidentally wiped out all my cron jobs. I'm not sure what I have done. I don't remember deleting entries from it by issuing crontab -e. What are the possible ways that the cron jobs can be ...
19
votes
2
answers
27k
views
Run a cron job every 5 minutes between two times
Is there a way to specify a job that runs every 5 minutes between some start time and some end time on business days in a crontab?
Update
I think it's relevant that my start and end times are not at ...
18
votes
2
answers
5k
views
Cron runs only once instead every minute
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04).
The /etc/echo.sh simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log ...
18
votes
4
answers
23k
views
ssh Permission denied only in cron job
Having a very strange problem. I've created a small bash script which runs a command on a remote host via ssh (using public key authentication).
When I run this script manually from the command line ...
17
votes
1
answer
13k
views
crontab day of week vs. day of month?
I added this to /etc/crontab on a few different linux & freebsd systems:
# monthly reboot: 3rd Tuesday of every month
56 07 15-21 * 2 root /sbin/shutdown -r now
I want a reboot on the 3rd ...
16
votes
6
answers
14k
views
Mac crontab is never created
I am trying to setup a cron on my mac, but it seems that it never finishes creating a crontab for my user. I open terminal and enter:
$ crontab -e
Which returns this:
crontab: no crontab for ...
16
votes
2
answers
15k
views
Multiple crontabs for one user
is there a way to use multiple crontab files for one user? Thinking something along the lines of crontab file per project instead of crontab per user...
Any help is appreciated...
15
votes
2
answers
34k
views
Behavior of rsync with file that's still being written?
If Apache is in the middle of writing a large file and an rsync cron job runs on that file, does rsync attempt to copy the file?
Example
Apache-1: Has file large being written to /var/www.
Apache-2: ...
15
votes
1
answer
56k
views
Why is my crontab not running
I have this cron
38 * * * * /bin/bash -l -c 'cd /var/rails/site/releases/20120705144335 && script/rails runner -e qa '\''Play.load_lists'\'''
I have this cron under the a different user so ...
14
votes
2
answers
16k
views
Where is my crontab file on OS X?
Moving to a new laptop I've lost my old cron setup.
I'd like to include it in my backup going forward.
Where is it located?
14
votes
4
answers
17k
views
Running mysql dump in a cron job without exposing passwords
I want to run
mysqldump -u aUser -p P4SSw0rd --all-databases > backup.sql
in a cron job. How can I do so securely?
I know I could put the command right there, but anyone with access to the ...
14
votes
2
answers
13k
views
How do I create a cron job that will commit my project changes to git on a weekly basis
I'm using git for the purposes of making a historical transcript of the changes made to my project. I understand it's not the ideal usage but it's the usage pattern I've chosen for various reasons ...
13
votes
4
answers
24k
views
Can I make cron "random"?
Maybe I'm completely nuts, and if so - that's fine. But how would I schedule a job to on-some-random-schedule broadcast a goofy message, like from fortune?
clarification
yes - this is my personal ...
12
votes
7
answers
35k
views
cron: run a process but only if it isnt running?
Is there a way for me to tell cron to run an app BUT not run it if a process exist already?
12
votes
5
answers
24k
views
Crontab deleted?
Instead of typing "crontab -e" I accidentally typed "crontab" and was stuck in the middle of a process so I aborted the process. Now when I go to crontab -e it's entirely blank. This isn't good at all....
12
votes
2
answers
6k
views
Common Mac OS folders/settings to check (when trying to get rid of a pesky self-launching app)
If there's an app that starts up by itself, what would the most efficient places to look for it be? Does anyone have a nice comprehensive list of where to check for Startup Items, Login Items, Login ...
12
votes
4
answers
18k
views
How to set cron PATH globally (i.e. for all users) permanently?
We need to have /usr/local/bin in cron's path for all users. Is there a way to set it system-wide, without needing to edit each individual user's crontab?
We've tried adding PATH to /etc/crontab:
# ...
11
votes
2
answers
15k
views
How do you use the run-parts command?
For some reason my crontab is not running the hourly/weekly/etc scripts.
It seems to be that run-parts is not working and I cant get it to work on my local machine as well. Is there a mistake in the ...
11
votes
5
answers
55k
views
Verify that a cron job has completed
Is there a command that can be run to verify that a users cron job has run successfully?
Platform is Ubuntu 8.04 LTS.
I have scripts in /home/useraccount/bin/
running
crontab -l
while logged in ...
11
votes
5
answers
30k
views
Timezone issue with cron
My cron jobs are computed one hour later compared to server time. I don't understand what is going on.
My configuration is the following :
Server time :
Europe/Paris
In /etc/default/cron I added ...
11
votes
8
answers
52k
views
Bad minute in crontab?
I get the following error in my syslog:
Oct 17 13:14:03 tracker cron[873]: (*system*) ERROR (Syntax error, this crontab file will be ignored)
Oct 17 13:14:03 tracker cron[873]: Error: bad minute; ...
10
votes
5
answers
4k
views
Cron can't find executable which works in terminal?
I've written a small tool in C++, compiled it, made it executable, and move it to /opt/tools/bin. The latter is a directory I created to store small, custom programs. I export it to $PATH in my ....
10
votes
5
answers
23k
views
how to make run cron on OSX 10.6.2?
Note:
this question is not about how to edit cron tab but how to make cron work
I edited my cron using env EDITOR=joe crontab -e
I entered 1 * * * * echo 'test' > /Users/radek/Backup/...
10
votes
2
answers
12k
views
Problem with $RANDOM in crontab
I've got a strange problem with $RANDOM in cron. I wish to execute a command a random number of minutes after the cronjob fires.
This example works directly in the terminal and delays the command up ...
10
votes
4
answers
16k
views
bash: using scp in cron job fails, but runs succesfully when run from command line
I am trying to use scp in a bash script run by cron (I am running this on Ubuntu 10.0.4 LTS).
The script works fine (i.e. transfers and copies file1 and file2 to/from the remote server, when I run it ...
10
votes
4
answers
25k
views
how to run cron jobs on GMT not local time?
How can I make cron jobs run on GMT, not local time?
this is my crontab file:
#m h d m wday command
TZ=GMT
5 0,6,12,18 * * * ~/Documents/bash/transfer.sh
my jobs seem to ...
10
votes
3
answers
55k
views
cron expression for every hour starting from specific time
Every one hour (starting from "now") I am able to schedule using this cron expression (expression) using nodejs cron-job.
But I need to set cron every one hour starting from a specific time. For ...
10
votes
4
answers
10k
views
How can I create a cron job that runs a task every three weeks?
I have a task that needs to be performed on my project schedule (3 weeks).
I'm able to set up cron to do this every week, or (for example) on the 3rd week of every month - but can't find a way to do ...
9
votes
4
answers
38k
views
Running Cronjobs as per Local Time rather than Universal Time
On running
dpkg-reconfigure tzdata
in terminal and i get 2 different time on my machine
Local time is now: Wed May 1 11:58:55 IST 2013.
Universal Time is now: Wed May 1 06:28:55 UTC 2013.
...
9
votes
2
answers
4k
views
Why does cron only offer minute granularity?
It feels like there are use cases for things you'd want to run once every 5 seconds, twice a minute, etc, but these are impossible with cron. Why hasn't second-level cron granularity been built into ...
9
votes
2
answers
7k
views
cron can't read PYTHONPATH environment variables?
I have added to the PYTHONPATH on my server's .bash_profile file. However it appears that cron isn't reading from it because I am getting import errors. If I run the exact command cron calls on the ...