View Full Version : script to delete
Mahir
13th November 2005, 19:39
Hello can anyone help me to make a script that everynight 02:00 linux automaticly empty 2 directory's?
/var/www/web2/web/mahir/png
/var/www/web2/web/mahir/tmp
is that possible ?
till
13th November 2005, 20:11
Hello can anyone help me to make a script that everynight 02:00 linux automaticly empty 2 directory's?
/var/www/web2/web/mahir/png
/var/www/web2/web/mahir/tmp
is that possible ?
Save this script as e.g. /usr/bin/emptydir.sh
#!/bin/bash
rm -rf /var/www/web2/web/mahir/png
rm -rf /var/www/web2/web/mahir/tmp
Then make it executable:
chmod +x /usr/bin/emptydir.sh
Then edit your crontab with the command:
crontab -e
and add a line:
59 23 * * * /usr/bin/emptydir.sh &> /dev/null
falko
13th November 2005, 22:56
and add a line:
59 23 * * * /usr/bin/emptydir.sh &> /dev/null
To run the cron job at 02.00h, the line should be
0 2 * * * /usr/bin/emptydir.sh &> /dev/null
till
13th November 2005, 23:25
You're right, seems I've not read the post completely :) Have not seen that a time was mentioned.
Mahir
14th November 2005, 13:21
/usr/bin/ulyaothdelete.sh
#!/bin/bash
rm -f /var/www/web2/web/gd-rppng/png/*.png
rm -f /var/www/web2/web/gd-rppng/tmp/*.txt
chmod +x /usr/bin/ulyaothdelete.sh
crontab -e
and i added
0 2 * * * /usr/bin/ulyaothdelete.sh &> /dev/null
So now this should be ok ?
till
14th November 2005, 13:31
but doesnt
#!/bin/bash
rm -rf /var/www/web2/web/mahir/png
rm -rf /var/www/web2/web/mahir/tmp
not delete the directory's png and tmp ? or does it only delete the stuff in it ? that's how i need it
It deletes the directories. If you only want to delte the contents inside of the directories, you can use this script:
#!/bin/bash
rm -rf /var/www/web2/web/mahir/png/*
rm -rf /var/www/web2/web/mahir/tmp/*
Mahir
14th November 2005, 18:03
Thank u verymuch :) it works perfect :D
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.