#1  
Old 13th November 2005, 19:39
Mahir Mahir is offline
Member
 
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Mahir Send a message via Yahoo to Mahir
Question 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 ?
Reply With Quote
Sponsored Links
  #2  
Old 13th November 2005, 20:11
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,007
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

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:

Code:
crontab -e
and add a line:

Code:
59 23 * * * /usr/bin/emptydir.sh &> /dev/null
Reply With Quote
  #3  
Old 13th November 2005, 22:56
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts
Default

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
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #4  
Old 13th November 2005, 23:25
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,007
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

You're right, seems I've not read the post completely Have not seen that a time was mentioned.
Reply With Quote
  #5  
Old 14th November 2005, 13:21
Mahir Mahir is offline
Member
 
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Mahir Send a message via Yahoo to Mahir
Question

/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.
Reply With Quote
  #6  
Old 14th November 2005, 13:31
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,007
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

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/*
Reply With Quote
  #7  
Old 14th November 2005, 18:03
Mahir Mahir is offline
Member
 
Join Date: Oct 2005
Location: The Netherlands, Apeldoorn
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Mahir Send a message via Yahoo to Mahir
 
Talking

Thank u verymuch it works perfect
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script questions && Gentoo version hagel Feature Requests 4 7th May 2006 14:19
Uninstalld Now Cant run older php script abselect Installation/Configuration 1 18th October 2005 10:23
DNS - call script to created named.conf entries on secondaries cstone Installation/Configuration 4 15th September 2005 02:16
Courier IMAP - when does it delete deleted messages?? hagel Server Operation 3 19th August 2005 00:52
can't delete a site KenMcGinnis Installation/Configuration 2 14th August 2005 16:02


All times are GMT +2. The time now is 12:29.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.