Questions tagged [cron]
cron is a task scheduler based on clock time that runs on Linux-based machines.
53
questions
80
votes
11
answers
141k
views
How can I get a script to run every day on Mac OS X?
Cron? Launchd? iCal??
If so, how?
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, ...
84
votes
13
answers
195k
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 ...
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 ...
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 ...
4
votes
2
answers
3k
views
rsync over SSH with cron in osx-environment
I want to automatically download files and folders from a Linux server to which I have an SSH (and FTP) account. The files shall be downloaded on a regular basis (I suppose a cron is the right tool to ...
3
votes
7
answers
12k
views
Automatically restart a Unix job if it goes down?
I have a job that I would like to "daemonize" on Unix: I want it to come up when the computer boots, and I want it to restart if it goes down.
A simple way to do this is to setup a cronjob that runs ...
101
votes
8
answers
184k
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
72
votes
2
answers
124k
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?
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: ...
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 ...
5
votes
3
answers
14k
views
Open a terminal from a Crontab
How do I get a gnome-terminal window to open from a crontab?
I have tried this:
* * * * * /usr/bin/gnome-terminal
* * * * * source /home/user_name/.bashrc ; /usr/bin/gnome-terminal
* *...
3
votes
2
answers
18k
views
crontab - /bin/sh: wget: command not found
I want to set up a crontab on my Macbook Pro running Lion. I run the usual crontab -e and provide a quick job to see if everything is working ok ---
*/10 * * * * wget -O - -q -t 1 http://site.local/...
1
vote
2
answers
3k
views
How do I make cron run a Java GUI application?
I have a script which runs a Java GUI application using "java -jar app.jar". I have added the script to the crontab to run every minute, check the processlist if the application is up. If it isn't it ...
1
vote
1
answer
573
views
Anacron running daily tasks hourly instead of daily
I have Anacron set up to run a backup daily, weekly and monthly. The monthly seems okay, but the daily and the weekly are running roughly every half hour every day!
Here is my /etc/anacrontab
# /etc/...
0
votes
1
answer
99
views
Shell script zips a folder, but exclude parameters not working IF its run from cron.daily
The script works fine if I run it with sh filename, but it ignores all the --exclude parameters if its run by cron:
#!/bin/sh
TIMESTAMP=$(date +%u)
WEEK=`date +"%V"`
if [ $(($WEEK%2)) -eq 0 ];
then
...
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
...
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 ...
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 ...
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 ...
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.
20
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 ...
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
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 ...
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:
# ...
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?
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
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
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 ...
8
votes
1
answer
26k
views
cron apparently requires a newline character on its own line at the end of the file
I'm trying to understand why cron is refusing to work with a certain crontab file. The manpage for crontab says:
cron requires that each entry in a crontab end in a newline character. If the ...
7
votes
4
answers
8k
views
cron runs but nothing happens
I have created a script called "forward_email.sh" and set permissions to 777. It contains the following line:
echo "It worked: $(date)" >> /home/noc/email.log
I created a cron job with the ...
7
votes
9
answers
3k
views
How can I write a cron job that will block my internet from 7pm to 7am? (So I can get some sleep)
I am using OSX 10.6 and it has cron built in. How can I write a cron job that will block my internet from 7pm to 7am every day?
Im sure this must be simple but I could only find one example online ...
5
votes
3
answers
11k
views
How do I automate borg backup?
Background
I would like to use Borg Backup as a backup solution for my Ubuntu server. They offer a very convenient sh script that they say you can just run as a cron job, but it is not working for ...
5
votes
4
answers
4k
views
with a shell script, it is possible to tell when it's run with cron vs run manually?
with a shell script, it is possible to tell when it's run with cron vs run manually?
UPDATE:
it was asked why I want to know. My cron job will be logging, and i want to be able to log if someone ...
5
votes
3
answers
11k
views
How to run a script at boot time for normal user?
I want to run a bash script at boot time in CentOS 6. I added the script in /etc/init.d/ directory but all these script are run by root. I want to run script for any user.
5
votes
2
answers
11k
views
Linux startup script to connect to bluetooth and cron to keep it connected
I have a mini Bluetooth keyboard and a Raspberry Pi running a Debian-based distro. I know the MAC address of the keyboard but for this question, let’s just use AA:BB:CC:DD:EE:FF. Right now I have to ...
4
votes
2
answers
43k
views
How to create a cron job to upload files to an FTP server
I would like to create a cron job that uploads files from a directory on my computer to my FTP server. I would like it to do it daily at midnight. I know pretty much nothing about cron, so I ...
3
votes
1
answer
405
views
certbot-auto fails to install automatic renewal?
I am using kernel 3.10 on CentOS 7. I have successfully installed CertBot 1.10.1 using alternative installation instructions as certbot-auto. Running certbot-auto successfully generated certificates ...
3
votes
3
answers
11k
views
Why does this script fail when run from cron, but works when run manually?
I have a relatively simple bash script that works great when invoked directly, but fails when run by cron. Why does this fail and how can I make it work via cron?
#!/bin/bash
apt-get update -y
apt-...
2
votes
2
answers
9k
views
How to properly use environment variables in crontab
I export a variable in my ~/.bashrc file (Ubuntu 20), which I'd like to use in a cron job.
Searching for answers, I found two ways of doing it, but none worked for me:
12 11 * * * BASH_ENV=/home/l86/....
2
votes
0
answers
113
views
why does this anacron job run hourly, not daily? [duplicate]
I'm running zulip on a virtual private server, and have created a script backup-zulip on my laptop (with ubuntu 20.04) to back up zulip via ssh. I want to run this script daily, so I put the line
@...
2
votes
1
answer
489
views
Schedule a cronjob everytime it is done
I have a cronjon which runs every 48 hours. But ideally what I want is that it must start running as soon as it stops. Can this be done? It is an sh script consisting of a python command.
I am using ...
2
votes
2
answers
3k
views
Why is this cronjob not working?
I have a ruby script in ~/custom_scripts/get_all_products.rb.
I want it to run every night at 04:00.
Here's what the cronjob in crontab -e looks like:
MAILTO="<email>"
0 4 * * * ruby ~/...
1
vote
1
answer
11k
views
Python script not running as cronjob
I have tried everything and I've seen other questions here regarding this but I cannot for the life of me run a python script as a cronjob.
I've tried the following.
* * * * * /usr/bin/python /home/...
1
vote
1
answer
1k
views
Cron scheduled backup script not working or writing to log file
I have a duplicity backup script set to run once per day through the root cron tab.
I set it up like this:
sudo crontab -e -u root
and added the line:
00 03 * * * root /home/[myusername]/...
1
vote
3
answers
8k
views
Starting script in screen with cron
I apologise if this has been asked before but I am not sure how to question a search query for this.
I am extremely new to linux and I have been learning as I go to solve issues.
I am trying to set ...
1
vote
2
answers
685
views
Running shell Script via Crontab
So I've tried to run a shell script via crontab.
My Crontabs look like this:
00 20 * * * $HOME/Bilder/Hintergründe/.background_skript/background_night.sh
and my background_day.sh looks like this:
`#!/...
0
votes
1
answer
375
views
Cron strange behaviour
I've got a Bash script with all the permission to be excecuted, I attach it to to a cron job, this script basically only kills and restarts a specific process. The strange behaviour is that if I run ...
0
votes
1
answer
11k
views
How to set cron expression to run first Weekday (MON-FRI) and first Weekend (SAT-SUN) of the month?
I tried for the Weekend (SAT-SUN) cron expression:
0 0 18 ? 1/1 SAT#1,SUN#1 *
but it didn't work.