Tag Info

Hot answers tagged

7

There's a package for that ;-). As well as cron-apt, which can be configured to perform certain upgrades automatically, another useful package is unattended-upgrades which is designed to safely apply security updates automatically. Beyond that, as Erathiel says it's not safe to run dist-upgrade automatically, but it's safe enough to run it manually every ...


7

sudo apt-get dist-upgrade is very safe to run as it won't do anything to the system, instead stopping to ask for your confirmation ;) You would have to add a -y switch, which is intended for unattended upgrades and makes apt assume that you always answer 'yes' to questions: sudo apt-get -y dist-upgrade. The man page states that If an undesirable ...


4

Ranges that wrap around like that are ambiguous. Specify the hours as 23,0-6 instead and avoid future problems. Cron checks every minute the contents of crontab files and if it founds coincidence of the time and the conditions it will run the script indicated on the line. For this case these is the set of coincidences that must be met: From 11 PM to ...


3

Generally, stopping and starting the system cron daemon is a bad idea. Commenting out the line isn't always convenient so here are a couple of related alternatives Use a semaphore One solution to this requirement is to use a semaphore - or flag - to indicate whether or not the script is permitted to run. In this instance the semaphore can be represented by ...


3

No, this is not true. The minimal step is one minute. But depend of service you want to run. Please share more details


3

00-01 09 * * * /home/flexsys/test.sh (the job will start at 9:00 and run upto 9:01) That is not what this means. This means the job will run at 9am and run again at 9:01. Cron has no concept of killing jobs, only starting them. As for the while, you need to run the date command, find the number of minutes, and test if it is or isn't 00. On my system ...


2

Fix the path so it's correct. Based on your comment it's likely to be /root/snmp_codes/snmp/snmpstats.py. You can also modify the command so that it captures stderr as well as stdout like this (the 2>&1 attaches stderr to stdout so you get both written to the logfile.log): * * * * * /root/snmp_codes/snmp/snmpstats.py -f file -g > logfile.log ...


2

The best ("correct") way to do it is to modify the command in the crontab so that it redirects its output; e.g., 50 12 27 4 1 java -jar HelloWorld.jar >> HelloWorld.output 2>&1 But, normally, when a cron job produces output that is not redirected, cron captures it and mails it to you.  Try typing mail and see what you get.  (If you have some ...


2

Your schedule as given is ambiguous, particularly as there are several different cron implementations available on Unix/Linux systems. I would strongly recommend that you specify two ranges to satisfy the wrap-around over midnight (but note that according to Crontab entry with hour range going over midnight the AT&T/BSD cron implementations can't handle ...


1

I need advice/best practice on how I can avoid keying in passphrase when I add this crontab to run everyday. Create a new ssh key with an empty password, specially for this task. Save it in a file, say, ~/.ssh/cron. Add its corresponding public key to ~/.ssh/authorized_keys on the remote machine. When you run your scp from cron(8) do it with the new ...


1

First, note that the current directory in a crontab is your home directory. You should put the full path to the script in the crontab. However, since your script is being executed, this isn't the problem. The likely problem is that your script requires an environment variable that is set in your normal session. Cron jobs run with a minimal environment, your ...


1

Edit your python program and let it check for a 'do not run' file first. If such file exists, exit your program i.e. import os.path if os.path.isfile('/tmp/disable_mypython'): exit() If you check for a file called for instance /tmp/disable_mypython you can easily 'disable' your program using: touch /tmp/disable_mypython and enable it again using: rm ...


1

The simpliest method I can think of is just to edit crontab and comment out the cronjob. Open crontab with: crontab -e And comment out # the line which is your cronjob.


1

Don't kill the cron daemon as it does a lot of tasks which are necessary to the system. Instead, edit the crontab file and comment out the cron job related to your script. (FYI, you do not need to restart the cron daemon after editing that.)


1

This will run your job every minute from 11:00pm to 06:59am on the days 1-5 of the week. Here 1 ==> Monday and 5 ==> Friday. However, cron will check that every condition is satisfied and on Friday, it will stop 12 midnight since Saturday is not included in the days. On all other days, it will work fine.


1

00 09 * * * /home/flexsys/test.sh #!/bin/tcsh cd /home/A/B/C/ @ a = 0 while ( $a != 12 ) sleep 5 touch ABC.txt @ a = $a + 1 end This will run your script only once, but it will touch your file 12 times with a 5 seconds pause between each touch. As long as 12*5 is 60, you'll have ...


1

This is the default (and the only) behavior. It is not explicitly documented, but is implied by systemd's operation logic. systemd.timer(5) reads: For each timer file, a matching unit file must exist, describing the unit to activate when the timer elapses. systemd(1), in turn, describes the concept of unit states and transitions between them: ...


1

If the first argument to the script is jobname and the second is command1 && command2 && command3 then the command you build up in the joined variable is something like command1 && command2 && command3>> /path/to/cron/log/dir/May_12_2015/jobname_2015-05-12_01-09-25.log 2>&1 You call eval on this string, and ...


1

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 * * * rsync -a -v --delete -e ssh ...


1

incron relies on inotify, which isn't emulated by Cygwin. To run on Windows it would have to be re-written using equivalent Windows functionality; see https://stackoverflow.com/questions/3517460/is-there-anything-like-inotify-on-windows for details. The answers to that question give links to various Windows tools which may provide the functionality you're ...



Only top voted, non community-wiki answers of a minimum length are eligible