VMware Cloud Community
Krede
Enthusiast
Enthusiast
Jump to solution

scheduling deletions of files

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) ?

Reply
0 Kudos
1 Solution

Accepted Solutions
fordian
Hot Shot
Hot Shot
Jump to solution

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

Reply
0 Kudos
4 Replies
RParker
Immortal
Immortal
Jump to solution

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.

Krede
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
oreeh
Immortal
Immortal
Jump to solution

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 !

fordian
Hot Shot
Hot Shot
Jump to solution

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

Reply
0 Kudos