Enthusiast
Enthusiast

scheduling deletions of files

Jump to solution

How do I make a script that runs ones a week at a specific time to delete some directory's in the filesystem?

(deleting some file backups that a make with a 3. party program) ?

0 Kudos
1 Solution

Accepted Solutions
Hot Shot
Hot Shot

For example a very simple way to do this for a single directory :

#!/usr/bin/perl -w

my $path = "/dir";

my $dir = "/test";

`rm -rf /$path/$dir`

If you can, give me for detail for the script you need.

Thank you

Dominic

View solution in original post

0 Kudos
4 Replies
Immortal
Immortal

Scripts are made with Perl. You want to search for perl scripting or Linux Perl Scripts, or Perl delete scripts, something like that.

Perl should be very easy to find, but normally functions that requires scripts aren't really a part of ESX, they are more a Linux support feature. Try a search on yahoo or google, you should find something.

Worst cast scenario, you can try your local bookstore and get a "perl for dummies" or perl scripting for beginners book if you can't quite get the right scipt.

Enthusiast
Enthusiast

How do I use cron to make the script run everyday at 23:00 clock?

0 Kudos
Immortal
Immortal

Create a crontab entry (either in the master crontab (/etc/crontab) or in a users crontab (crontab -e) ) with the following format

0 23 * * * root scriptfile (master crontab format)

0 23 * * * scriptfile (users crontab format)

make sure to replace the spaces with tabs !

Hot Shot
Hot Shot

For example a very simple way to do this for a single directory :

#!/usr/bin/perl -w

my $path = "/dir";

my $dir = "/test";

`rm -rf /$path/$dir`

If you can, give me for detail for the script you need.

Thank you

Dominic

View solution in original post

0 Kudos