
13th November 2005, 19:39
|
|
Member
|
|
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
script to delete
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 ?
|

13th November 2005, 20:11
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 19,805
Thanks: 285
Thanked 1,805 Times in 1,357 Posts
|
|
Quote:
|
Originally Posted by Mahir
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
Code:
#!/bin/bash
rm -rf /var/www/web2/web/mahir/png
rm -rf /var/www/web2/web/mahir/tmp
Then make it executable:
Code:
chmod +x /usr/bin/emptydir.sh
Then edit your crontab with the command:
and add a line:
Code:
59 23 * * * /usr/bin/emptydir.sh &> /dev/null
|

13th November 2005, 22:56
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Quote:
|
Originally Posted by till
and add a line:
Code:
59 23 * * * /usr/bin/emptydir.sh &> /dev/null
|
To run the cron job at 02.00h, the line should be
Code:
0 2 * * * /usr/bin/emptydir.sh &> /dev/null
|

13th November 2005, 23:25
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 19,805
Thanks: 285
Thanked 1,805 Times in 1,357 Posts
|
|
You're right, seems I've not read the post completely  Have not seen that a time was mentioned.
|

14th November 2005, 13:21
|
|
Member
|
|
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
/usr/bin/ulyaothdelete.sh
Code:
#!/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 ?
Last edited by Mahir; 14th November 2005 at 13:30.
|

14th November 2005, 13:31
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 19,805
Thanks: 285
Thanked 1,805 Times in 1,357 Posts
|
|
Quote:
|
Originally Posted by Mahir
but doesnt
Code:
#!/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:
Code:
#!/bin/bash
rm -rf /var/www/web2/web/mahir/png/*
rm -rf /var/www/web2/web/mahir/tmp/*
|

14th November 2005, 18:03
|
|
Member
|
|
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank u verymuch  it works perfect
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 08:48.
|
Recent comments
1 day 15 min ago
1 day 5 hours ago
1 day 5 hours ago
1 day 5 hours ago
1 day 6 hours ago
1 day 9 hours ago
1 day 11 hours ago
1 day 11 hours ago
1 day 11 hours ago
1 day 13 hours ago