-1

I'm very new to linux and not sure what the best solution would be for the following.

I want to run a HTTP GET request every 5 seconds. I imagine some kind of service that I can start/stop at will.

I'm not bothered about the response, as long as the web server is hit. So I can throw away the response.

What's the best way to do this? I'm using a CentOS based VPS.

Thanks for any help.

MeshMan
  • 101

1 Answers1

9

You're Doing It Wrong.

I'm pinging a web-service to start a background job at fixed interval times - exactly every 15 minutes of the hour 00:15, 00:30 etc. So I ping a PHP script that determines if it's time to run, and runs if so

Which means what you really want to do is Run a task exactly every 15 minutes of the hour.

You should be using cron for this, but not the way you're thinking. You want to either:

  • Create a crontab entry like */15 * * * * /command-to-run on the server where you want the job to run.

or alternatively

  • Create a crontab entry like */15 * * * * wget http://script-to-starton some remote server with a reliable clock.

(If */15 isn't what you want 15,30,45 probably is -- that excludes the top of the hour).

Refer to any decent crontab(5) man page for more details.

voretaq7
  • 80,749