Questions tagged [cron]

Cron is a job scheduler that allows users to run commands periodically.

Filter by
Sorted by
Tagged with
0 votes
2 answers
40 views

How do I declare and use a variable in crontab that will hold the name of the admin user account?

I want the crontab for root to be agnostic, i.e. I don't want to literraly specify in it that the admin user is jim. That is why in my crontab for root I introduced the variable au. SHELL=/bin/bash ...
John Smith's user avatar
0 votes
1 answer
84 views

shell .sh script does not execute all tasks within, except when run manually [duplicate]

I run a shell script at reboot, by having it in my crontab: @daily apt-get update && apt-get upgrade -y @reboot bash /root/Start.sh @reboot /bin/bash -c 'sleep 10 && /bin/mount -a' ... ...
Marco's user avatar
  • 101
0 votes
1 answer
19 views

Trying to periodically backup /var/log while using journald

I'm trying to periodically backup my /var/log directory, but journald manages the logging on my system. Is the correct way to just tar -cf log.tar /var/log? The way journald saves it's log files in /...
user9503's user avatar
0 votes
1 answer
28 views

Anacron doesn't appear to run anything on Debian, but why? [duplicate]

I have an odd problem with my Debian server. Up until a few weeks ago, anacron was running my cron jobs fine and I can see I have backups from then so it was running stuff. Then it appears to have ...
Jez's user avatar
  • 958
0 votes
0 answers
18 views

Allow cronjob to restart systemclt user unit

I have a systemctl user unit: [Unit] Description=my app Wants=network.target After=syslog.target network-online.target [Service] Type=exec ExecStart=/home/user/bin/myapp StandardOutput=append:/home/...
Mark's user avatar
  • 713
0 votes
0 answers
35 views

Systemctl Suspend Inside Cronjob

I have a cron: * * * * * /usr/local/bin/script 2>/tmp/cron.log And the script: #!/bin/bash if <some validation>; then systemctl suspend fi So I get the error when cron executed: Call to ...
rhuanpk's user avatar
  • 385
0 votes
1 answer
58 views

What is the meaning of a trailing hyphen in this crontab command? [duplicate]

I was looking into how to programmatically add a cronjob, and came across this SO question which advises using the following one liner: (crontab -l 2>/dev/null; echo "*/5 * * * * /path/to/job -...
Pacopenguin's user avatar
0 votes
0 answers
22 views

How to automatically start mate-terminal the CLI way on every system start?

UPDATE - replies to the comment section - base posting after that: I really wanna do it the CLI way - reducing my GUI dependence as a user. So, you think I'd better head into the direction of ...
futurewave's user avatar
3 votes
0 answers
53 views

rsync cronjob succeeds during the day but always fails to find the destination at night. Might my external hard-drive "go to sleep"?

NOTE: there is an easy solution to this problem (i.e., just backup your data during the day!), so this is not an urgent problem. But I have searched extensively on stack exchange and askubuntu and ...
HB.'s user avatar
  • 31
0 votes
1 answer
26 views

crond not sending mail to non-root user

RHEL8 system here. Outputs from /etc/cron.daily... produce the expected email output, but my user's own crontab doesn't. Here's a test that sums up my problem: ~$ crontab -l MAILTO=dh * * * * * ...
musbur's user avatar
  • 103
0 votes
0 answers
43 views

anacron not running weekly scripts

/etc/anacrontab: # /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ...
laur's user avatar
  • 537
0 votes
1 answer
34 views

CLASSPATH in crontab

I am having trouble getting my Java program to run from cron. I am able to recreate the problem, using a simple example, as explained below: In the file /path/to/javaenv.txt I define my CLASSPATH ...
Sandeep's user avatar
  • 139
0 votes
4 answers
140 views

Cron Job: Best Practices

I have written a bash script which will be setup as a cron job in the future. During the script development I have added echo lines to help me follow and debug my code, like the code snippet below: #!/...
hymcode's user avatar
  • 81
0 votes
1 answer
82 views

using a cron job to automatically backup the same drive using dd

so I want to backup my system drive (full drive not just partition) every month using dd, in an external hard drive. So I have something like this in my crontab 0 9 1 * * dd if=/dev/sda | gzip -c &...
vzografos's user avatar
0 votes
0 answers
41 views

Date format in /var/log/cron (Oracle Linux Server 8.8)

Currently the date format in /var/log/cron seems to be %b %d %H:%M:%S, so in /var/log/cron I see the logs like Aug 20 03:13:01 bhost1 CROND[1361808]: (user1) CMD (......) Is it possible to change the ...
StefanG's user avatar
  • 101
2 votes
1 answer
334 views

When you alter permissions of files in /etc/cron.d in Ubuntu, do they persist across updates?

It seems like an no brainer question, but i did not manage to any real information. In my Ubuntu server i have created a custom /etc/cron.d config file, e.g. /etc/cron.d/MyCronTab, the reason I put ...
aprlo's user avatar
  • 23
0 votes
1 answer
72 views

Cron execution not normal

When I run job.sh in terminal, it works. In there there's just following: #!/bin/bash cd /home/user node script.js > file When I run it from CRON, it just creates file and no text is there, if I ...
Fuzzy System's user avatar
3 votes
1 answer
106 views

Is there a tool to test if a date-time is in a given range?

I need to develop a script to test if "now" (e.g. the output of date) is in a given range. For now, this range is expected to be a list of days of month (e.g. 10,11,12,13,21,22,23). And I ...
Juh_'s user avatar
  • 133
0 votes
1 answer
53 views

cronjob: run script_A on boot/wake, then every 5 mins after that, run script_B on each of the 4 mins in between (so *not* just modulo-5 clock-minutes)

So I'd like to set up a cronjob in a very specific way: run script_A on boot/wake then every 5 minutes after, relative to that boot/wake (so not just modulo-5 clock-minutes) run script_B on each of ...
dwawlyn's user avatar
  • 23
0 votes
1 answer
29 views

`cronnext` reports `nextstring` for every-minute cronjob as beginning of the *current* minute, ie in the *past*. Normal?

So I'm seeing this weird thing (or at least, weird to me, with my tiny amount of experience). cronnext tells me the nextstring for an every-minute cronjob is the beginning of the current minute, ie ...
dwawlyn's user avatar
  • 23
0 votes
0 answers
187 views

How to update google-chrome on centos with yum-cron?

I'm managing a medium size Selenium grid based on Linux CentOS 7 - a total of a couple dozens linux VMs. I'm using yum-cron to install updates. Starting recently, google-chrome does not update ...
Aleks G's user avatar
  • 181
1 vote
2 answers
66 views

Turn on keyboard backlight from multi-user.target

Is there a way to turn on the keyboard backlight from the multi-user.target environment? As X11 is not loaded, the command xset led on does not work and gives xset: unable to open display ""....
Bill Joe's user avatar
0 votes
0 answers
53 views

xfconf-query not working when called from cron / how to run UI dependent programs per cron?

When running /usr/bin/xfconf-query -v -c xfce4-desktop \ -p /backdrop/screen0/monitorHDMI-1/workspace0/last-image \ -s $HOME/Photos/somephoto.jpg on the command line, it sets the background image ...
Harald's user avatar
  • 888
0 votes
0 answers
144 views

Why is my systemd-timer not working? (Active = Until)

I created a systemd-timer which should restart a docker container daily but it never does. That uptime of the docker container is > 1 day, that shows me the container was not restarted /lib/systemd/...
3x3cut0r's user avatar
0 votes
1 answer
33 views

Accessing interactive output of command started in crontab

I'm running a game server (Minecraft) on Raspberry Pi OS. I want the server to start whenever the device starts so I've added the following line to crontab: @reboot user cd /home/user/nukkit &&...
Leonardo Petrucci's user avatar
13 votes
1 answer
2k views

When a file path longer than 100 characters is passed, crontab throws an error saying "No such file or directory"

$ touch aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBBB $ crontab ...
Chris Stryczynski's user avatar
3 votes
6 answers
840 views

Update crontab rules without overwriting or duplicating

I'm trying to figure out a good solution to the following problem: crontab contains some default rules (A,B,C) I have a setup.sh script that should append rules from a file my.cron to crontab (...
Tabish Mir's user avatar
-1 votes
2 answers
170 views

Why are comments in the same crontab line as the crontab job are not allowed?

It might depend on my none native English but the crontab.5 manpage contradicts itself. Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) ...
buhtz's user avatar
  • 816
0 votes
0 answers
41 views

Crontab job with grep and ls -ltr [duplicate]

I am trying to schedule a job using crontab, but it is not giving any output. The same thing I am able to do through a script, and is solving my problem. But I would like to know what mistake I am ...
Saad Azhar's user avatar
0 votes
0 answers
27 views

How can I use crontab to delete a specific folder name [duplicate]

I've created some folders with a year-month stamp on them (ex: 2023-03). I've tried creating a crontab script to delete folders older than 2 months. In the directory I would have folders like 2023-03 ...
Derek Chen's user avatar
0 votes
0 answers
79 views

Crontab jobs during suspend will not run?

Environment: Linux XUBUNTU 22.04.2 LTS on an ACER ASPIRE laptop. Tools: Using Linux Text Editor to create a bash script also tried using crontab to execute each command a minute apart. Goal: To have ...
J. Mander's user avatar
0 votes
1 answer
50 views

mandb generates all possible languages in /var/cache/man

In Debian 12, the following command is run weekly: start-stop-daemon --start --pidfile /dev/null --startas /usr/bin/mandb --oknodo --chuid man -- --quiet which generates man caches in /var/cache/man ...
Martin Vegter's user avatar
0 votes
1 answer
95 views

Using '/usr/bin/cd' in a cron script fails while 'cd' works

I have a simple shell script that I am running via cron. I am using it to perform a scheduled git pull operation (yeah, I know there are probably better methods, but this is another team's repository ...
Nick S's user avatar
  • 103
0 votes
2 answers
112 views

save the output to multiple files in crontab

There is a script scheduled in crontab. 0 2 * * * /usr/local/bin/backup.sh >> /root/output_all.txt I want to save the output into multiple files like output_all.txt and output_date.txt at the ...
Hardguy's user avatar
  • 49
0 votes
1 answer
122 views

Schedule a cron task to be repeated every day?

All the google results mention cron jobs. They don't work, I followed multiple guides exactly, and the script is never launched. I just need to set the brightness to change at morning and dusk, it ...
indeedwatson's user avatar
0 votes
0 answers
125 views

My Crontab doesn't work on Raspberry Pi

I have a python script in: /home/pi/auto/wake_up.py crontab -e: * * * * * /usr/bin/python /home/pi/auto/wake_up.py >> /tmp/wake_up.log log is created but with empty line same when I put #!/usr/...
JOC0N's user avatar
  • 13
0 votes
1 answer
188 views

What things can be done to make a Bash script containing sudo commands, running with the timer schedule ‘crontab’ work?

I try to run a script that I named script1.sh: out="/home/me/scripts/out.txt" sudo ntpdate 99.99.99.99 >> $out on a timer with the crontab in a Centos 7 operation system. The aim of ...
SFriendly's user avatar
  • 101
1 vote
1 answer
82 views

Cron works at 5pm instead of 5am

I have this /etc/cron.d/reboot file: PROJECT_ROOT=/usr/local/share/applications/ana NODE_PATH=/usr/bin/node REBOOT_SCRIPT=/usr/sbin/reboot SCRIPT=scripts/server-reload-messages.js 0 5 * * * root cd $...
kolserdav's user avatar
  • 111
0 votes
0 answers
33 views

solaris 10 code below works fine, but is nothing is ever generated via cron

root crontab 20 * * * * [ "$(ls -A /var/spool/lp/requests/localhost/)" ] && echo "lp queue not empty " || echo "lp queue empty" | /usr/ucb/mail [email protected] ...
visedawk's user avatar
0 votes
1 answer
132 views

Fixing a cronjob issue when running a script and cron task being deactivated [duplicate]

I am running OpenSUSE 15.4 and I am trying to set up a CRON job using crontab -e. Inside my CRON tab I have the following: */1 * * * * /usr/bin/Rscript /run/media/matt/A34E-C6B8/folder/myRScript.R So ...
user113156's user avatar
3 votes
1 answer
203 views

What effect has "+:ALL:cron crond" in /etc/security/access.conf?

I am refining our rules in /etc/securiy/access.conf. I found the following rule and I am not sure what it is used for: +:ALL:cron crond According to the man page of access.conf it means something ...
N. Kreienbühl's user avatar
2 votes
2 answers
998 views

Schedule a job every 20 days [duplicate]

I want to know whether there is any easier way to run a job every 20 days. In cron job, if you specify the day parameter as */20, it'll run only on 20th day of each month, IE basically becomes once ...
xpt's user avatar
  • 1,354
0 votes
1 answer
182 views

How to make Linux reboot every 30 days even if the clock gets corrupted

I'm running a headless networkless raspberry pi zero to control some hardware**, and occasionally the time/date gets corrupted, maybe other things too. While it's not a perfect fix, rebooting the ...
Al Ro's user avatar
  • 213
0 votes
1 answer
1k views

Cron Job vs. Scheduler: Understanding the Differences and Use Cases

What are the key differences between a Cron job and a scheduler, and in what use cases is using one of these tools more appropriate than using the other?
orchard's user avatar
0 votes
1 answer
89 views

Allow a certain set of domain names corrisponding ip with resolution and whitelisting on the fly

I'm trying to setup a firewall config for a specific machine. The firewall is configured to block all traffic except for a certain set of allowed IPs. Today I was asked to put on a teamviewer service ...
user3450548's user avatar
  • 2,816
0 votes
2 answers
741 views

Run shell script file once after reboot

I am stucked on how to execute a shell script only once after the machine reboots, the file that I have has the following content where I am writing a test to get only the first element from the file: ...
zeus's user avatar
  • 1
0 votes
0 answers
82 views

Cron doesn't run the Cron Job I wrote [duplicate]

I wrote a Cron Job and it doesn't run. Any Idea why it doesn't run? This is the Cron Job I expect to run: # # # (day of month) (day of week) # min hou dom (day ...
michal roesler's user avatar
3 votes
0 answers
160 views

A monotonic systemd timer that is not distorted by suspension and downtime?

This is what I want: A timer that runs every X minutes by the wall clock. If the computer is asleep, then it should run as soon as it wakes up. And then again and again, every X minutes by the wall ...
Jortstek's user avatar
  • 233
0 votes
0 answers
211 views

SSH/Cron services hangs on RHEL 8.6

So, i have an odd issue with my VM RHEL 8.6 test server with Hyper-V. The problem is the SSH Service hangs from time to time, around midnight. To connect again to the server i have to Reboot it ...
xnanitox's user avatar
  • 101
0 votes
0 answers
142 views

Using systemd timers every hour with multiple commands

First time user trying to switch from cron to systemd timers. Currently I have a crontab with the following line: 10 * * * * cd /some/where; export ENV_VAR=...; ./executable with params Is such cron's ...
xpt's user avatar
  • 1,354

1
2 3 4 5
47