Showing posts with label scheduled task. Show all posts
Showing posts with label scheduled task. Show all posts

Thursday, January 20, 2011

How to Automate the Disk Cleanup Tool in Windows XP

Open a command line window, then launch Cleanmgr.exe /sageset: n to choose the clean-up option. The n variable can be a number from 0 to 65535. When finish press the "Ok" button.
The command Cleanmgr.exe /d C: /sagerun: n perform a full clean-up of the c: drive with the options you set previously.

Now you can easily schedule this operation with a simple cmd file.

Wednesday, March 25, 2009

crontab - scheduled tasks in Linux

crontab is a file which contains the schedule of cron entries to be run and at what times they are to be run.
A cron schedule is a simple ASCII text file. Each user has their own cron schedule. You can edit it only with the crontab command. The default text editor is usually vi

usage:
crontab -e add or edit a scheduled task
crontab -l list the the scheduled tasks
crontab -r remove all scheduled tasks

syntax:
you have 6 positions, 5 for the time, 1 for the command to execute

* * * * * command_to_execute
| | | | |
| | | | |_Weekday 0-6 (0 = Sunday)
| | | |___Month 1-12
| | |_____Day 1-31
| |_______Hour 0-23 (0 = midnight)
|_________Minute 0-59

some example:
30 8 * * * rm /home/{username}/temp/*
this entry remove all files in temp directory every day at 8:30 AM

5,35 * * * 1-5 rm /home/{username}/temp/*
this entry remove all files in temp directory from monday to friday every hour at minute 5 and 35

30 8 * * * rm /home/{username}/temp/* >/dev/null 2>&1
this is the same as the first example but with no email notification and no log file

30 8 * * * rm /home/{username}/temp/* > /home/{username}/logfiles/emptytemp.log >/dev/null 2>&1
this is the same as the first example but with no email notification and the log file redirected to a custom location (> to replace the old log file with the new one, >> to append new log file to old one)