Questions tagged [cron]

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

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

User input in cronjob

I have created a script which calls another script.I'm implementing this via below cronjob 55 12 * * * cd /backup2 && ./script2.sh The another script ,I'm calling(restore1.sh) requires ...
0
votes
0answers
24 views

can't run sh script from crontab [duplicate]

my script: #!/bin/sh PATH=$PATH:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin if pgrep -x "firefox" >/dev/null then return else firefox & fi my crontab: * * * * * /home/...
0
votes
1answer
42 views

I can check output of a command in shell script but I cannot do the same in crontab

I can run my script as .sh file in ubuntu shell but it does not work when it is called from cron job.I run my script into an ubuntu container (using docker) as if [ `java -jar /path/to/my.jar |grep -...
0
votes
2answers
2k views

Cron jobs have stopped working due to PAM

My cron jobs have stopped working on my CentOS 7 server. The server is running WHM/cPanel. It seems like it is an issue with PAM service because in /var/log/secure I can see the following errors when ...
1
vote
1answer
185 views

How to schedule a python script cron job that have packages in virtual environment?

I have my env where I installed all needed for me packages. And where I have my script that I want to put to the crontab. What I did, but there are a problem that when crontab running my script, of ...
0
votes
0answers
25 views

Cron Job (shell script) seems to work, but doesn't add anything to the log file like when I run it manually

#!/bin/bash # CHANGE THESE auth_email="user@example.com" auth_key="c2547eb745079dac9320b638f5e225cf483cc5cfdda41" # found in cloudflare account settings zone_name="example.com" record_name="www....
0
votes
1answer
89 views

Cron to Bash Script to Bash Script to Expect Script

I want to execute a series of Expect scripts. The chain of execution goes like this: Cron job starts a bash script, this wrapper starts ~11 bash scripts in Parallel - each of them call an Expect ...
0
votes
0answers
14 views

How can I rebooting whes there hasn't been an ssh session in a while?

I have a Raspberry Pi with a problematic sshd. Periodically, it just starts refusing connections and will continue to do so until restarted. I could spend hours debugging that or I could just make a ...
0
votes
2answers
2k views

still getting Removing leading `/' from member names with tar -C option from cron email

I am trying to get rid of the "Removing leading" messages from a cron that runs a backup job with tar. The emails still have these messages, and I'm using cronic to only send emails when there are ...
0
votes
1answer
225 views

crontab and scp file transfer via script

I have a script that exports logs from log management server and send those exports to the archiver server. When I run this script manually, it complete it's task without any problem. It download ...
2
votes
0answers
112 views

hourly cron job runs fine except at midnight

I have a cron job which is set to run hourly using 0 * * * *. The command is to run a postgres query and output to a file: 0 * * * * psql foo -f /home/foo/stats.sql >> /home/foo/stats.txt This ...
4
votes
1answer
725 views

Do scripts in /etc/cron.hourly and /etc/cron.daily, etc., get executed automatically?

I've understood that the entries in /etc/cron.d/ are executed automatically. But I have also found these in /etc/ /etc/cron.daily/ /etc/cron.hourly/ /etc/cron.monthly/ /etc/cron.weekly/ In /etc/cron....
31
votes
10answers
89k views

How to restart the Python script automatically if it is killed or dies

I am running my Python script in the background in my Ubuntu machine (12.04) like this - nohup python testing.py > test.out & Now, it might be possible that at some stage my above Python ...
1
vote
1answer
43 views

Command working in CLI but not in cron

I'm trying to set up a cron job via cPanel on a machine running CloudLinux/CentOS. The command should run a PHP script every minute to update stats; cd /home/account/public_html/phpredmin/public/ &...
0
votes
1answer
462 views

bad hour errors in crontab file, can't install

I want my crontab to be every 4 hours but from a certain time 1 pm: I chose this config: 0 1/4 * * * but if I save I get the error: bad hour errors in crontab file, can't install. This following ...
0
votes
0answers
18 views

how to post cronjob output in terminal (Ubuntu) [duplicate]

I'm just a beginner with linux A have a simple test_script with echo "testtesttest" And a cronjob with * * * * * /home/<user>/test_sript and MAILTO="" to get this testmessage every minute. ...
2
votes
2answers
3k views

Cron job gives no output

I tried to schedule my first cron job as follows: crontab -e The file had some comments at the top, and on the first line after those, I put * * * * * date I expected the date and time to be ...
0
votes
1answer
276 views

Python script runs manually but not in cronjob

So this is a super weird issue. I have a python script that calls many bash commands via subprocess.call based on certain criteria. Now, the script runs just fine manually but when thrown into a ...
0
votes
1answer
2k views

Crontab to reboot nightly and start shell script

I have the following command that runs a shell script that launches several python scripts for me on reboot: @reboot sh /home/pi/repos/launcher.sh >/home/pi/logs/cronlog 2>&1 I want to ...
1
vote
1answer
1k views

Crontab and Tmux not playing well together

So I want my server to run a script which starts several tmux sessions on boot. This is my crontab: @reboot . /home/steven/.profile; /home/steven/Scripts/Start.sh And this is the content of my ...
0
votes
4answers
1k views

crontab is launching multiple java process every 5 minutes?

I have a java runnable jar which I need to run it if it not running or got killed for some reason so I decided to use crontab for this - I need to run the crontab as "poppetapp" user so I am logged ...
0
votes
1answer
267 views

Cronjob fetching JSON with cURL. Check if response isn't empty before writing to file

I'm running Ubuntu and got a simple cronjob fetching a remote JSON-file and (over)writing it to the server. */15 * * * * /usr/bin/curl -m 120 -s https://path/to/remote/json.json > /store/json/here....
1
vote
1answer
26 views

Cron is not logging stderr in /var/mail/user

I have this user who have a lot of cron jobs and I expected it to log stderr in its /var/mail/user. Sample below cron entry is working as expected in a different server. * 30 * * * * /usr/local/bin/...
6
votes
4answers
41k views

Crontab error: no crontab For [user]

I'm seeing an error every time I do the command below. Why? $crontab -l no crontab for server where server is the user account. This issue comes about because the script in crontab doesn't work, so ...
0
votes
0answers
138 views

Linux Crontab Segmentation Fault

For some reason, my crontab is giving me segmentation fault (core dumped) error when ever I attempt to access it using crontab -l or crontab -e. Everything is fine if I access the root crontab or ...
0
votes
2answers
163 views

How to delete rogue cron job [duplicate]

Hello everyone, My machine has been hijacked by a bitcoin miner. he has a cron job that runs every 2 seconds. Using crontab -e to delete it doesn't work because it respawns soon after. ...
1
vote
2answers
574 views

Crontab and NMCLI

I have created a script called connection.sh, it is used to automatically connect to my vpn : #!/bin/bash nmcli connection up MyVPN I have already tested it, and it works if I launch it manually, ...
0
votes
0answers
21 views

Crontabing Scrumblr screenshot

for a monitoring purpose, once a week, I need to capture some Scrumblr board. So cron will be used. But how can I get a snapshot/screenshot for an URL ? This runs on CentOS release 6.3 (Final) ...
1
vote
2answers
125 views

Why is SHELL pointed to /bin/sh in a Csh script?

Yes, I know C-shell is bad. No, I did not choose C-shell. Yes, I would prefer to use a proper shell. No, I cannot switch to a better shell. I have a very simplistic script: /tmp/env_test.csh #!/...
1
vote
1answer
57 views

Why does my every-minute crontab not work but same process on @reboot works fine?

I've been following carefully and reading a lot about setting up crontab with crontab -e any help is appreciated on this ... I have a process that runs on startup (reboot) that works perfectly, and ...
0
votes
1answer
129 views

Prevent cronjob's from writing to /var/mail/$USER?

In macOS, cronjobs configured with crontab have the command output and/or error messages (if the cron doesn't succeed) written to the /var/mail/$USER file. Can this be prevented? I've tried: * * * * *...
1
vote
1answer
49 views

Cron Job Console Connect and Root Permissions

I'm working on a script for user Bob with the relevant parts shown below. Problem I'm having is if I put this cronjob under user Bob, zenity will work but shutdown wont. And if I put it under root ...
29
votes
8answers
94k views

Why did my crontab not trigger?

I used crontab -e to add the following line to my crontab: * * * * * echo hi >> /home/myusername/test Yet, I don't see that the test file is written to. Is this a permission problem, or is ...
2
votes
2answers
4k views

Default umask for cron jobs

How to set default umask for cron jobs, please? (On RHEL 6.) Jobs are started under non-interactive (obviously) no-login (?) shell. Not only I prefer dash over bash. But consider also bash called as /...
0
votes
1answer
16 views

CronJob command to delete multiple subdirectories by name in a given directory

I have two IP cameras which are sending image snapshots to an FTP server every 10 seconds, from 08:00 to 20:59. The directory structure looks like this: `-- public_html `-- securitycams |-...
9
votes
1answer
977 views

Is it possible to (7 day) schedule sleep time of a hard drive?

I'm looking for a way to schedule when an external hard drive connected to my Linux (Debian 9) box goes to sleep (stops spinning). To put this into content: I have a Linux box that runs as a ...
6
votes
3answers
5k views

Display cron job times in a human-friendly format

Is there a way to display or is there a tool that can parse a crontab expression and display it in a human-friendly way? 10 6 * * * sh /usr/local/crons/file_check.sh For example, for the above cron ...
0
votes
2answers
271 views

How should I run a cron command which has forever loop?

I have a script that have "while true" loop. And I want to run that script from cron on every minute, so that when the process is killed (or is failed - no matter why) cron will run the script again. ...
18
votes
4answers
88k views

Cron running job every 15 seconds

Could you advise me what to write in crontab so that it runs some job (for testing I will use /usr/bin/chromium-browser) every 15 seconds?
2
votes
0answers
35 views

How to start at boot a service that lives within a user's schroot?

Due to legacy (aka corporate) reasons, I have a number of servers running recent Debian versions (Debian 9, Debian 10) that also need to run older services such as MySQL 5.5. This is done via a (pre-...
2
votes
3answers
1k views

Cron only occasionally sends e-mail on output and errors

On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable: (echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable" This is ...
1
vote
0answers
36 views

Rsnapshot log entries: “Number of hard links > 1”

I just noticed that my syslog is being spammed by rsnapshot, writing <host name> cron[1100]: (*system*rsnapshot) NUMBER OF HARD LINKS > 1 (/etc/cron.d/rsnapshot) every minute or two. It ...
0
votes
1answer
25 views

SMB Not Able to Use Date Command Substitution

smbclient //10.10.101.29/it -W WORKGROUP -U user --password pass -c 'put ./file_$(date +%Y_%m_%d).file ./folder/file_$(date +%Y_%m_%d).file' The above does not work & gives me an error stating: ....
0
votes
2answers
198 views

cron jobs printing to /dev/stdout

I want to setup a job that prints output to /dev/stdout, but cron is intercepting it, and sends an e-mail instead crontab -l */1 * * * * echo "hiccup" >> /dev/stdout 2>&1 this is the ...
0
votes
0answers
35 views

How to run script via cron and get same results as terminal? (Centos 7.2)

I have a complicated question (I understood that's related to environment variables). I'm running a script via termial as follows: "bash install_version.sh" script contains: #!/bin/bash /root/...
-1
votes
2answers
240 views

Is it possible to recover a deleted file from crontab -r? [duplicate]

I made a very serious mistake. I was editing the crontab file of my remote server, I was as the root user and it turns out that I wrote crontab -r instead of crontab -e and without previous notice it ...
1
vote
1answer
235 views

cronjob [ -x /usr/lib/php5/sessionclean ] returns command not found

I'm running PHP 5.6 on an Debian 8 machine and hence there is a cronjob running as root for cleaning up session data: 09,39 * * * * root [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/...
1
vote
0answers
14 views

How to implement a worker system using only Cron?

I have a PHP web application with a particularly slow endpoint and I have diagnosed that this is being caused by a complicated function call. It is not essential that the function call is completed ...
2
votes
2answers
96 views

How to set cron job for every 5 hours

Can I use below code to set cron job for every 5 hours? 0 */5 * * * script.sh What time my script.sh will be executed? 0000, 0500, 1000, 1500, 2000, 0100, 0600, 1100, 1600, 2100 and so on... OR ...
5
votes
2answers
8k views

How to build a cron docker image properly?

I am trying to build a Debian-based image to dockerize a cron process, but my cron jobs are never started. Here is my Dockerfile: FROM debian:jessie RUN apt-get update && apt-get install -y --...