Questions tagged [cron]
Cron is a job scheduler that allows users to run commands periodically.
2,170
questions
0
votes
1
answer
18
views
Run a tmux new session with cron, then run a command
I have in my cron that auto starts a service inside a tmux if it detects that its not running. The rest of my bash script works, but if the tmux session doesn't exist, it throws an error. Which is why ...
1
vote
1
answer
25
views
Does cron run graphical applications as root?
I've automated a daily restart for Firefox (edited by running crontab -e) and forgot to take into account whether the program would launch with administrator privileges.
killall -s SIGTERM firefox; ...
1
vote
1
answer
22
views
xdotool returning different output when executed from crontab [duplicate]
So I was making a script that monitors my app usage. It does so by running a cronjob every minute, and cronjob in question checks which window is focused on and increments its counter by 1.
Other ...
0
votes
0
answers
25
views
CentOS Linux 7 cronjob validate the expression and check if it will run
I do have a CentOS Linux 7. On /etc/crontab I added my command that I want to run:
0 0 20 * * root MySpecificCommand
I do have three questions:
How can I check if my expression is valid and and what ...
0
votes
1
answer
24
views
Debian - Execute a python script with modules import
In Debian 10 (buster) I wan't to schedule a task with cron. This task is a python script who create a csv file. This python script start with:
import xmlrpc.client
import csv
When I execute it, ...
0
votes
0
answers
34
views
cron is no longer logging, but it seems to be running
I am running Ubuntu 20.04 as a server on a remote machine.
I have confirmed that cron is running as a service:
$ sudo service cron status
● cron.service - Regular background program processing daemon
...
0
votes
0
answers
25
views
Struggling with du, php and crontab
Unix numpty here.
I have written a PHP script which I am running from a crontab every so often. Part of the script is a du command from which I extract certain directory sizes which I put into a JSON ...
0
votes
3
answers
46
views
Can I run a script on reboot once?
CentOS9
Keeping in mind this question: https://serverfault.com/questions/1099284/centos-how-to-keep-previous-service-state-on-reboot
It seems that it is not possible to achieve what I need. Is that ...
1
vote
1
answer
48
views
A basic Bash script (to start a GUI program) works partially in cron
I use this script to restart Firefox overnight (to apply the package manager and addon updates):
#!/bin/bash
killall -s SIGTERM firefox; sleep 15
firefox -P "user" &
firefox -P "...
0
votes
0
answers
24
views
Scheduled cron job not running on MacOS [duplicate]
Here is my crontab.
3 13 * * 1-5 * * * * * /Users/smveerap/cron.sh >/tmp/cronStdout.log 2>/tmp/cronStderr.log
0 12 * * 1-5 * * * * * /opt/homebrew/bin/python3 ~/git/bashFiles/gitUpdate.py >/...
2
votes
1
answer
65
views
Wildcard expansion doesn't happen when Bash script invoked from cron under macOS
I have a Mac mini running macOS Monterey, and it has InfluxDB running in a Docker container. I'm trying to set up a nightly cronjob via a shell script I'm calling to back the data up, zip it, and only ...
2
votes
1
answer
496
views
What effect does a dot character . have in a crontab?
I have picked up a habit of including . from some blog post:
0 0 * * * . /usr/local/bin/somescript.sh
...instead of:
0 0 * * * /usr/local/bin/somescript.sh
For instance a visual cron schedule ...
0
votes
0
answers
81
views
Bash variable is empty depending on cron schedule frequency. If every 1, 5, 15, or 10 minutes, there is a value. If every 30 or top of hour, empty
I've got a cron scheduled bash script I am seeing odd behavior with. As the title says, there is a single variable that is either empty or not after the script runs depending on the cron schedule. If ...
0
votes
1
answer
37
views
Python Scrips on Raspberry - ssh works, cronjob doesn't
I wrote a python script that checks a website and eventually sends an email. I copied the script to my raspberry and when I execute it via ssh it works fine. But when I let it execute by the crontab ...
1
vote
1
answer
146
views
POSIX (or portable) way to forward emails from crontab
I've got an installer/updater script that's meant for IRIX/Linux/macOS/FreeBSD and I would like to extend its compatibility to Solaris.
I've already fixed a few parts that weren't POSIX compliant, ...
0
votes
1
answer
35
views
crontab doesn't create screen session
I am trying to use
@reboot /usr/bin/screen -dmS nfc /home/pi/.nvm/versions/node/v17.8.0/bin/npm run --prefix /home/pi/nfc/ dev
to run my script in /home/pi/nfc/ on startup. Sadly after rebooting, I ...
1
vote
0
answers
10
views
Audio in Qt6 application does not work if run from cron of systemd
Ubuntu 21.10, Qt 6.2.0.
In my QML I have a MediaPlayer:
MediaPlayer {
id: mediaPlayer
videoOutput: videoOutput
audioOutput: audioOutput
onErrorOccurred: { console.log(mediaPlayer....
0
votes
0
answers
21
views
How can I get Vim to give me different tab settings for crontab?
I would like to be able to keep the temporal expressions in my crontab neatly organized in columns, with a key above every 5 or so entries, like so:
#m h dom mon dow command
30 6 * * * /...
0
votes
0
answers
21
views
RHEL 7 - Crontab runs only under /etc/cron.d
noobs here.
As my first step I edited the crontab as usually:
# crontab -e
0 2 * * * /root/backup.sh
The above, for some reason, never starts.
Instead, if I create a backup job under /etc/cron.d, the ...
1
vote
0
answers
38
views
ModuleNotFoundError
The problem is that when the script is running through cron, for some reason the module is not found, but if you run it directly through Python, then everything is fine
Cron:
*/5 * * * * python /home/...
0
votes
1
answer
65
views
rtcwake not executed as root cron job
This rtcwake job launched manually works fine :
$ sudo rtcwake -m no -u -t $(date +%s -d 'tomorrow 07:30')
but doesn't seem to run as a root cron job :
$ sudo crontab -l
32 7 * * * rtcwake -m no -u -...
0
votes
1
answer
36
views
I need to run custom processes with crontabs
I need to run custom processes with cron-tabs, every 15 days but varying the day, for example
00 18 */15 * 4
00 1 */15 * 1
The days are never fixed, they always vary, is this possible?
Thank you
0
votes
0
answers
15
views
Extracting columns added during the last minute from the csv file
I wrote a script that runs sql * loader every minute to drop the data from the csv file into the database. However, it needs this script to extract data from the last minute csv file, and not read ...
1
vote
0
answers
25
views
mdadm rotate hot spare
It can be a good idea to have a hot spare in some RAID systems. It can be a bad idea for the hot spare to sit idle for months/years, potentially hiding a defect, until an active drive fails and ...
0
votes
1
answer
100
views
CRON 2>&1 >/dev/null vs >/dev/null 2>&1 [duplicate]
I just created a tiny shell script to be run every minute.
What happened was that it started flooding my mail.
$ crontab -l
* * * * * /home/user/bin/test 2>&1 >/dev/null
I changed the ...
1
vote
1
answer
108
views
How to run a command from terminal so that it will be executed without tty?
The situation: I have a bash script that is intended to run with cron. I tested the script on the terminal and it was running fine. As I configured the script to be executed by cron, the script ...
0
votes
1
answer
55
views
Debian - Schedule a SQL query with crontab
I wan't to schedule a SQL query in a PostgreSQL database with a crontab.
In terminal, in root, when I run:
psql -U postgres -d my_database -h localhost -p 5432 -c "INSERT INTO schema.table (name) ...
2
votes
1
answer
202
views
Is sudo crontab -e and sudo cat /etc/crontab the relevant one for cron?
$ sudo cat /etc/crontab
# ...comment lines elided...
0 0,12 * * * root sleep 1347 && certbot renew -q --post-hook 'sudo reboot'
sudo crontab -e shows
13 0,12 * * * root sleep 1347 && ...
0
votes
2
answers
147
views
Retry cron job on failure
I have a cron job that can fail periodically when resources are not available. Waiting awhile and trying again is the best way to handle such failures. What is the best way to do this? Have the ...
0
votes
1
answer
214
views
Crontab is overwritten by HiveOS on boot
I am trying to add some additional cronjobs to a rig running on HiveOS. Every time I add a job to crontab (for example one for duckdns) it disappears after the reboot. I've noticed that the crontab ...
1
vote
1
answer
47
views
bash script in cronjob cannot execute /sbin/fake-hwclock
I've edited my root crontab to periodically execute a script:
sudo crontab -e
Which should execute the following script, located on a mounted USB, as root:
* * * * * /mnt/usb0/fake-hwclock-cron.sh
...
3
votes
1
answer
26
views
Crontab scheduling for specific option
I need to add a crontab entry which runs every quarter ,on second sunday ,at 02 am.
Which of the below one is correct? the OS is AIX.
00 02 8-14 */3 0 && /myscript.sh
or
00 02 8-14 */3 * [...
1
vote
3
answers
130
views
Running a python script via cron at a random time between 10AM-11PM once every day
I'm on ubuntu and need to run a python script once every day randomly between 10AM-11PM. Right now I've only got it running at a fixed hour, I've seen a few examples but mostly for repetitive tasks ...
0
votes
0
answers
9
views
CalendarAgent issues
I am trying to disable CalendarAgent on my MAC; It consumes CPU cycles with no value. I have tried to find the default list of processes that et launched automatically. Need to figure out how to edit ...
0
votes
0
answers
71
views
Recently my speedtest-cli only runs as sudo not root?
This has worked in my script for years but now something is goingon.
I can run sudo speedtest-cli as any user and it work.
As root if I use in cron or execute under root I get this error:
Retrieving ...
0
votes
1
answer
194
views
schedule cron job for every hour is not working
I am running a single instance cron job for certain task. My script looks like below:
# every hour interval
0 * * * * php /project/yii daily/order
# every 30 minutes interval
*/30 * * * * php /...
1
vote
1
answer
190
views
Cron not sending email, command line email works
I have installed ssmtp on an raspberry pi running Raspbian 10 Buster. Email from the command line, e.g. using mail works fine. However, I have also configured a user's cron job to send email by adding ...
0
votes
1
answer
39
views
Anacron kills children of my task
I wanted to set up an anacron task to run a backintime backup once a day (Ubuntu 20.04.3 LTS). If you schedule this using the backintime GUI, the normal crontab is being used, but for my use case this ...
0
votes
1
answer
98
views
Why doesn't anacron run the tasks scheduled?
I've set anacron to run several tasks, but it seems to fail due to some sort of weird permissions error.
This is my anacrontab:
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and ...
0
votes
0
answers
26
views
Run cron job on linux with http user - Elastic Beanstalk
I have a webserver running Symfony and I want to run a periodically, I also use AWS and AWS Elastic Beanstalk
There is documentation where explains how to add a cronjob, although as soon as I add the ...
0
votes
0
answers
28
views
Crontab echo job sent to a file doesn't work [duplicate]
I have the crontab job here to echo every minute:
* * * * * /bin/echo "hello world!" >> /home/mrpennymiser/echos.txt
I am using Kali Linux WSL for Windows. I am using full paths but ...
1
vote
1
answer
620
views
Cron job to delete all files older than 7 days: -exec rm -f {} \; vs -delete [duplicate]
I want to run a cron job which deletes .txt files older than 7 days. I have two commands.
The first command:
/usr/bin/find /var/www/example.com/wp-content/targetdir -name "*.txt" -type f -...
0
votes
1
answer
21
views
Logrotate scenarios - Mix and match cron.daily and daily directive
The file:
/etc/cron.daily/logrotate
has the following statement:
/usr/sbin/logrotate /etc/logrotate.conf
The logrotate.conf file has the weekly directive defined inside.
Now I have two rotational ...
0
votes
1
answer
48
views
What should be the preferred approach while rotating logs - using the daily directive or putting the file path in cron.daily? [closed]
While doing log rotation, we have two options -
Using the daily directive in the logrotate file -
/var/log/wtmp {
daily
minsize 1M
create 0664 root utmp
rotate 1
}
Putting the ...
1
vote
1
answer
50
views
Print the cron time in human readable format
After researching enough on the times when cron.daily (and weekly and 'hourly') run, I found the following command -
grep run-parts /etc/crontab
But the output of this command isn't very intuitive. ...
0
votes
1
answer
119
views
Make cron inherit XDG_RUNTIME_DIR
I have a cron job that runs emacsclient which requires that XDG_RUNTIME_DIR to be set. I can set the variable to something like /run/user/1000 in the crontab but then this assumes that the owner of ...
0
votes
3
answers
488
views
cron.service file not found
My backup script works fine when executed manually; but nothing runs from crontab.
I am running Fedora 35 Workstation.
The crontab editor works:
$ crontab -e
The cron daemon is not running. Each of ...
0
votes
3
answers
73
views
What is the easiest way to run a program from time X to time Y?
There is a certain potentially failing process that I want to run until it succeeds, during the night time, say, from 23:00 to 7:00, but not later.
A possible solution would be to:
Add a cron job for ...
0
votes
0
answers
26
views
What is the most efficient way to run a task every X hours of runtime, accumulated over all power-ons?
Let us assume that I have a machine which wakes up at 7:00, does some work, usually for 15 minutes, but sometimes for days (e.g., experiment supervision), and after the works is done, it powers ...
0
votes
1
answer
46
views
Pass multiple directories to find in Mac for removing .DS_Store files
I have a defined list of directories that contain development code that I want to make sure that any .DS_Store files are never present, or removed shortly after being created.
I will do this via ...