I run this via crontab every one minute on my machine occasionally to see if a process is eating up my system's resources.
this command can be added to crontab so as to execute a nightly backup of directories and store only the 10 last backup files.
This is not exhaustive but after checking /etc/cron* is a good way to see if there are any other jobs any users may have set. Note: this is a repost from a comment "flatcap" made on http://www.commandlinefu.com/commands/view/3726/print-crontab-entries-for-all-the-users-that-actually-have-a-crontab#comment, for which I am grateful and I take no credit.
usage = crontest "/path/to/bin" This version of this function will echo back the entire command so it can be copied/pasted to crontab. Should be able to be automagically appended to crontab with a bit more work. Tested on bash and zsh on linux,freebsd,aix Show Sample Output
Usage example: display output of a command running in the background at desired time
The example in details: report disk quotas and that backup process will start soon
In my /etc/crontab file I added following four lines for weekly automatic incremental backup:
.
52 13 * * 7 root mount /dev/sda3 /media/da2dc69c-92cc-4249-b2c3-9b00847e7106
.
53 13 * * 7 knoppix5 df -h >~/df.txt
.
54 13 * * 7 knoppix5 env DISPLAY=:0 /usr/bin/gedit ~/df.txt && wmctl -a gedit
.
55 13 * * 7 root /home/knoppix5/rdiff-backup.sh
.
line one: as root mount media for backup on Sunday 13:52
line two: as user knoppix5 write out to text file in home directory the free space of all mounted disks on Sunday 13:53
line three: in front of you open and display a very simple text editor (I prefer gedit) with content of previously reported disk usage at Sunday 13:54
wmctl -a gedit means (from the manual):
-a Switch to the desktop containing the window , raise the window, and give it focus.
line four: as root run incremental backup script rdiff-backup.sh as root on Sunday 13:54
.
my rdiff-backup.sh, with root permissions backups in short time (writes only changes from the last backup) the etire linux system (except excluded - i.e. you don't want backup recursively your backup disk), looks like this (Show sample output):
Show Sample Output
Show the crontabs of all the users. Show Sample Output
With this you can unlock your KDE4 session via SSH, via mobile phone SSH or e. g. scheduled task in crontab (without asking password). Useful when you need to grant somebody access to your locked profile remotely. Create an alias (e. g. as "unlock") and use with remote KDE4 lock. This works only on KDE4 boxes because KDE 3 is using utility with another name. Tested on Kubuntu 8.10.
I needed to add a line to my crontab from within a script and didn't want to have to write my own temporary file.
You may find you need to reload the crond after this to make the change take effect.
e.g.:
if [ -x /sbin/service ]
then
/sbin/service crond reload
else
CRON_PID=`ps -furoot | awk '/[^a-z]cron(d)?$/{print $2}'`
if [ -n "$CRON_PID" ]
then
kill -HUP $CRON_PID
fi
fi
The reason I had CRON_HOUR and CRON_MINS instead of numbers is that I wanted to generate a random time between midnight & 6AM to run the job, which I did with:
CRON_HOUR=`/usr/bin/perl -e 'printf "%02d\n", int(rand(6))'`
CRON_MINS=`/usr/bin/perl -e 'printf "%02d\n", int(rand(60));'`
Every 20 minutes ping host with IP address 192.168.0.14. If it's not 'alive' or not reachable, then display something eye-catching (here xeyes) on the desktop.
Hint for newbies: edit crontab with
crontab -e
Just put this line in a file that resides in your /etc/cron.d/ folder, and you're set. The -q option is used to suppress php headers.
Lists crontab for all users on system that have crontabs. Show Sample Output
Every 20 minutes test if host with IP 192.168.0.14 is 'dead' or not reachable. The line should be put in your crontab file.
this lets you edit a crontab file (which may be used as a backup as well) and insert this into your crontab. this way is especially handy, when multiple users are working on one account (e.g. root)
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: