Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Script to Delete Folder Automatically? 2

Status
Not open for further replies.

tyhand

Programmer
Jul 3, 2002
186
US
Hey all,

Anyone know of a good standard script I can use to run a Cron Job to delete a folder on my site automatically on a daily basis?

If not, can anyone recommend a good resource for me to learn some basic Unix scripting for me to accomplish this task?

Thanks all!

- Thank
- You
- Have
- A
- Nice
- Day
 
man crontab (-e option)
man rm (-r option)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Remember also that cron runs in it's own environment, with minimal variables like PATH etc set, so it's as well to use fully qualified paths to rm etc when using it. If you're a novice user, it's sometimes as well to edit a copy of the crontab to work on, only activating it when you're happy that it will work. Do the following to make a copy:

crontab -l > croncopy.txt

edit croncopy.txt with vi or another editor of choice

activate the new crontab when you're happy with it:

crontab croncopy.txt

Bearing this in mind it might be as well to make a copy of crontab (again crontab -l > crontab.good) to keep in case your new one doesn't do the business and you can backtrack with:

crontab crontab.good

HTH.

Some days are diamonds, some days are rocks - make sure most are the former.
 
Hi fellas,

Thanks for the replies... but, I'm a newbie to this.

Where do I put those lines of code?... the "(man crontab (-e option) man rm (-r option) )"

From what I understand, it should go in a text file; then get the path to that file within Cron? Is this correct?

Thanks again! Much appreciate it.

- Tyhand

 
Hi

Tyhand said:
Where do I put those lines of code?... the "(man crontab (-e option) man rm (-r option) )"
The [tt]man[/tt] ( comes from manual ) is a tool which displays the documentation for the entity specified as parameter. So [tt]man crontab[/tt] will display the documentation of the [tt]crontab[/tt] command.

The [tt]man[/tt] tool is primarily interactive, so you should type the [tt]man crontab[/tt] ( and similar ) command at the command prompt.

How to use the [tt]man[/tt] command is described in its own man page. You can display it with the [tt]man man[/tt] command. Additionally see the Man page article on Wikipedia.

Note that your system may have another similar tool, [tt]info[/tt]. It is newer and easier to navigate.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top