I have many crons that run at different intervals. I need to configure them all to not run between two specific time ranges. How can I configure a unix cron to run exclusive of 11:45-13:00 and 14:45-16:00?  If the minutes is not possible, 12:00-13:00 and 15:00 - 16:00 would suffice. Thanks!
589
This is a  about using cron &amp; crontab.   You have been directed here because the community is fairly sure that the answer to your question can be found below. If your question is not answered below then the answers will help you gather information that will help the community help you. This information should be edited into your original question.  The answer for 'Why is my crontab not working, and how can I troubleshoot it?' can be seen below.  This addresses the cron system with the crontab highlighted.
18461
I have a script that works when I run it from the command line, but when I schedule it with cron I get errors that it cannot find files or commands.  My question is twofold:   When I schedule a cron job using crontab -e, does it use my user ID as the basis for its permissions?  Or does it use a cron user ID of some sort and its related permissions? When a cron job is launched, what is the working directory?  Is it the directory where I specify the script to run, or a different directory?   Here is my cron job:  15 7 * * * /home/xxxx/Documents/Scripts/email_ip_script.sh   Here is the actual script:  vIP_ADDR="`curl automation.whatismyip.com/n09230945.asp`" echo "$vIP_ADDR" sed "s/IPADDR/$vIP_ADDR/g" template.txt &gt; emailmsg.txt ssmtp XXXXX@gmail.com &lt; emailmsg.txt   Here are the errors I get when I view the mail message produced by cron:  sed: can't read template.txt: No such file or directory /home/xxxx/Documents/Scripts/email_ip_script.sh: line 15: ssmtp: command not found   It cannot find the template.txt but it resides in the same directory as the script.  It also cannot run ssmtp, but I can as my user.  What am I missing to get this to work properly?
10531
Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?  To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a way to have another cron job running which would remove the oldest files in that directory until there are less than, say, 5.  And just to be clear, there's only one file present, it should never be deleted.
52034
I'm curious as to what other administrators' experiences with timezones, in the context of remotely administered servers, are. In my career I've come across several conventions;   Always, always, always use UTC.   Always, always, always use the timezone of wherever base HQ is. Use the local time of the people who happen to be administering.  Use the local time of the server location.    In some places, I've come across multiple and conflicting conventions. My own preference has been to use UTC, always - with no daylight savings. But for one reason or another, it seems that most people prefer to use some concept of local time, with daylight savings. Although it seems like a straightforward technical matter, discussions around changing conventions always seem to trend towards religious schisms.  What are you using? What do you consider to be the advantages and disadvantages of each approach?
13127
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.  How do I add Cron jobs in Ubuntu?
38824
I am running CentOS 5.3 and would like to log all messages from the "at" daemon. My syslog.conf contains the following entry:  cron.* /var/log/cron   I assumed that cron line in syslog refers to the entire family of "cron, anacron, at and batch". However, while cron and anacron actions seem to get looged, "at" actions do not get logged. How do I log atd actions?  Thank you for your attention   (Added) I would like to add the contents of my syslog.conf just in case there is an error:  # Log all kernel messages to the console. # Logging much else clutters up the screen. #kern.*                         /dev/console  # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;authpriv.none;cron.none        /var/log/messages  # The authpriv file has restricted access. authpriv.*                      /var/log/secure  # Log all the mail messages in one place. mail.*                          -/var/log/maillog   # Log cron stuff cron.*                          /var/log/cron  # Everybody gets emergency messages *.emerg                         *  # Save news errors of level crit and higher in a special file. uucp,news.crit                      /var/log/spooler  # Save boot messages also to boot.log local7.*                        /var/log/boot.log
47615
We have a job that is set to run Monday thru Friday. Up until two weeks ago, it ran fine 5 days a week. For the last two weeks it has failed on Monday. I am unable to locate where to find the point of failure.   ### Example Scripts 0 2 * * 1-5 /admin/scripts/example.exp 1&gt;/dev/null 2&gt;&amp;1   We run AIX 7.1.  I've looked in the /var/log/ and there is no cron file there. Looking for advice to add to this so we can troubleshoot.   I found that the log is located in /var/adm/log. Further we are getting this error repeatedly ever since this date/time. How do I clear this max limit?  c queue max run limit reached Fri Nov 25 21:52:00 2016 ! rescheduling a cron job Fri Nov 25 21:52:00 2016
15217
I finally set up a realistic backup schedule on my data through a shell script, which are handled by cron on tight intervals. Unfortunately, I keep getting empty emails each time the CRON has been executed and not only when things go wrong.   Is it possible to only make CRON send emails when something goes wrong, ie. my TAR doesn't execute as intended?  Here's how my crontab is setup for the moment;  0 */2 * * * /bin/backup.sh 2&gt;&amp;1 | mail -s "Backup status" email@example.com   Thanks a lot!
74016
Trying to set up a daily cron job to shut down a server.   One source suggests editing /etc/crontab  Another suggests crontab -e (with sudo)  I tried the latter, and my process did not run (if I recall, it was 30 23 * * * shutdown -h)   I also note that in the nano editor, it was working on a .tmp file? (top of nano says: /tmp/crontab.9zeTNt/crontab )  What is going on? How can I fix this?
104065
The Case: I need to run some commands/script at certain intervals of time and for this I have two options:  set up a cron-job implement a loop with sleep in the script itself.  Question: Which is the better option from resource consumption point of view, why? Is cron the better way? Does cron use some kind of triggers or something making it efficient over the other? What procedure does cron use to check and start the jobs?
77159
I have a job that I would like to "daemonize" on Unix: I want it to come up when the computer boots, and I want it to restart if it goes down.  A simple way to do this is to setup a cronjob that runs every 10 or 20 minutes. The cronjob should restart the application if it's not already running.  How do I write this last part of the script: "If the job is not currently running, then start the job"?
114752
I have a script that scans a directory and does some maintenance on the files in it. Another process creates the files in the directory (10 - 30 files per day).   The script is called via a daily cron job . What I need is to trigger the script on an event (each time a new file is created in the directory). I prefer this rather than increasing the frequency of the cron job.  How can I do that? is there a command or a program to install?  Thanks in advance for any help.
72970
I have this command that I run every 24 hours currently.  find /var/www/html/audio -daystart -maxdepth 1 -mtime +1 -type f -name "*.mp3" -exec rm -f {} \;   I would like to run it every 1 hour and delete files that are older than 1 hour. Is this correct:  find /var/www/html/audio -daystart -maxdepth 1 -mtime **+0.04** -type f -name "*.mp3" -exec rm -f {} \;   I am not sure of my use of the decimal number??  Thanks for any corrections.  EDIT  OR could I just use -mmin 60? Is this correct?  EDIT2  I tried your test, good thing you suggested it. I got an empty result. I want all files OLDER than 60mins to be deleted! How can I do this?? Does my command actually do this?
93543
I want to schedule jobs with at, but I'm not sure what happens if the computer is suspended at the specified time: Will the command be executed as soon as the computer wakes up again (like with anacron) or will it not be executed at all (like with cron)?     If you specify a job to absolutely run at a specific time and date in   the past, the job will run  as  soon  as possible.   That's what the manpage says about that, however it doesn't quite match my case: I don't want to specify a job to run in the past, I want to run it in the future and ask how at will treat it if the computer is sleeping then.  This is not a duplicate of  because this question asks whether at will wake up the computer to execute the command, neither is it a duplicate of  because this is about how to prevent at from executing  those “old” jobs (with a very good answer though!).
44847
I tried to schedule a command to execute 2 minutes later  at -c "ls -l" now + 2 minutes  It fails with multiple ways  $ echo "open 'Google Chrome' " | at now + 2 minutes job 15 at Mon Oct 29 13:31:42 2018   How could I enable it working?  run "open 'Google Chrome' "  at now + 2 minutes   I tried, it is not working  $ at now  at&gt;ls -l at&gt;^D at&gt; &lt;EOT&gt;  job 18 at Mon Oct 29 15:55:00 2018
62982
I have a cron job that runs every minute on an Ubuntu 12.04 box  $sudo crontab -e * * * * * mylogin /pathto/file.sh &gt; /log/filelog   If I run file.sh, the bash script does some stuff and echos out runs:  $ ./file.sh  runs   If I check the log of cron tab it shows that the job is running:  Jul 10 12:41:01 localhost CRON[1811]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog) Jul 10 12:41:01 localhost CRON[1810]: (CRON) info (No MTA installed, discarding output) Jul 10 12:42:01 localhost CRON[1813]: (root) CMD (mylogin /pathto/file.sh &gt; /log/filelog)   However, the script is not running. It is not doing it's work and not echoing runs to /log/filelog.  $cat /log/filelog  #shows nothing   What other steps can I take to debug this problem?
15108
We need to accomplish the following:  On the 1st day of each quarter, we would like to update all open opportunities that have "close date" in the past quarter and set the new "close date" to be the last day of this new quarter.  I'm new to SFDC, but from my research it seems triggers or Time-dependent workflow may not do this. Can we write and schedule a cron script to do this?  Any help will be greatly appreciated! Thanks!