Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Cron Job to Delete the files in folder after 30 minutes

picypicy Member
edited March 2013 in General

I need the code of the cron job which will delete the files in the folder which was created 30 minutes before.

Comments

  • run it every 30 minutes, then just make it execute a script that tells it what files/folders and where they are?

  • CiriumCirium Member
    edited March 2013

    Your best bet is to find a script (I'm sure their are many) on google that deletes files based on their time (in your case 30min), then just schedule it every 1 minute in the crontab.

  • picypicy Member

    Am using this

    /40 * * * * rm -rf /var/www/vhosts/mp3/

    but the above deletes every 30 minutes. But i need the code which delete after the file get 30 minutes old

  • find /path/to/folder -mtime -30m -exec rm -i '{}' \;
    
  • eastoncheastonch Member
    edited March 2013

    30 * * * * rm -rf /var/www/vhosts/mp3/ ?

  • MunMun Member

    0,30 * * * * rm -rf /var/www/vhosts/mp3/* will delete @ the top and bottom of the hour for every hour.

  • picypicy Member

    I have setuped a delet.php file. I need that to be executed every 15 minutes how?

    @George_Fusioned @Mun

  • 15 * * * * php /path/to/ur/file

  • picypicy Member

    @Cirium said: 15 * * * * php /path/to/ur/file

    Not working :(

  • MunMun Member
    edited March 2013

    0,15,30,45 * * * * php /path/to/ur/url

    edit: or */15 * * * * php /path/to/ur/url

    :)

  • raindog308raindog308 Administrator, Veteran
    edited March 2013

    @George_Fusioned nailed it - you have to use find. But I think you want rm -f, not rm-i

  • MunMun Member

    Dats snappy mate.

  • @raindog308 said: @George_Fusioned nailed it - you have to use find. But I think you want rm -f, not rm-i

    Ah, I was first writing my reply saying he should use -i to test it out first.
    Then I was sure it's correct, so I edited my post, but forgot to change the -i :D

  • erhwegesrgsrerhwegesrgsr Member
    edited March 2013

    @George_Fusioned said: find /path/to/folder -mtime -30m -exec rm -i '{}' \;

    It makes me happy to see some true bash programming :-) Not the way too easy overused PHP

Sign In or Register to comment.