2

I am currently developing a website. Users can post ads which are added in a database. I would like to delete these ads when they are more than 60 days old. To do so, I will write a PHP script which will find such ads and delete them from the database.

Right, it's easy. But how do I execute this script without loading a page every day in my browser ? How do I ask to my server to execute it automatically regularly ?

Thanks !

PS : I am on a shared server, not a dedicated one. Does it make cron use not possible ?

4
  • 3
    With cron jobs: en.wikipedia.org/wiki/Cron Commented Feb 3, 2011 at 14:00
  • 1
    There are 3rd-party sites that can visit your site regularly. I use cron-job.org personally, although. it's in german. Commented Feb 3, 2011 at 14:07
  • Here is a guide for cron jobs on shared hosting servers: drupal.org/node/117351. FYI I use dreamhost, and they offer cron job support, so you should be all ok. Commented Feb 3, 2011 at 14:09
  • Seems to be an interesting solution.. Commented Feb 3, 2011 at 14:11

2 Answers 2

5

Is it Unix/BSD/Linux hosting? Then you are after cron jobs.

Sign up to request clarification or add additional context in comments.

3 Comments

I am on a shared server, not a dedicated one. Can I use cron anyway ?
Well, ask your hosting provider. There's a big chance that you have cron jobs on you account.
Prisoner answered first ;) +1 anyway.
4

Using the following:

  • Use cron to automate the task (more info)
  • If you wish to have the page as a web page you'll want to use wget to load the web page (more info)
  • Alternatively, use PHP from the command line by doing something like /path/to/php /path/to/script.php - you need to make sure you give this file (script.php) executable permissions. (more info)

Edit: You can use cronjobs on a shared server, what control panel is available to you? (cPanel, Plesk, etc.)

4 Comments

I am on a shared server, not a dedicated one. Can I use cron anyway ?
It's a specific interface (of a french host provider). I will check if it's proposed in my interface.
It should be, almost all hosts provide cronjobs.
Right, there is this feature. Thanks ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.