creating a php script that runs like a cronjob?

  • Thread starter Thread starter Ahmed Alrasheed
  • Start date Start date
A

Ahmed Alrasheed

Guest
hello there
since my hosting Cpanel doesn't support Cronjobs

isn't there a way that allows me to automatically preform an action ( like deleting all the contents of a folder ) using php code ?

my dir will be
/uploads

and i want to to delete all of the folder contents every 6 hours

thanks in advanced m8s
 
I'm not sure how you would do the task every 6 hours without a Cronjob but in php there is a built in function called shell_exec() which executes commands via shell and then returns the output as a string.

I've personally never used this function in php but I would assume the code would be

$results = shell_exec('rm * ~/uploads');

Hope that helps.
 
Use the unlink() function.
http://us.php.net/manual/en/function.unlink.php

And have a single PHP web page that calls itself using Javascript's settimeout() feature to call itself every 6 hours. Then open it one time in your browser and leave the browser up.
 
Back
Top