Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web page at

I want a cron job to automatically hit this page every night at 2 am. I was going to get cron to run a PHP script that opens the website with CURL like so:

        $bocURL = '';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $bocURL);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $bocFile = curl_exec($ch);

Is there a way for me to do this directly from a cron command without having to write PHP script?

share|improve this question
0 2 * * * /usr/bin/wget --quiet --output-document=/dev/null # get page at 2am, do not save output, be quiet – L.R. Mar 4 '10 at 20:20
up vote 10 down vote accepted

The command wget is a good solution for this problem if you are accessing a script on a remote server. However, if you are running the cronjob on the actual host that is "" you may just want to schedule crobjob to execute the code sitting at /process/2909.

For example, we have some PHP jobs that we execute with cron. Rather than using an HTTP request that could take minutes (and potentially cause timeout issues) we setup a cronjob that calls "php5 /srv/cronJobs/2909.php" - This invokes the PHP interpreter and is not subject to HTTP timeouts. Additionally, this PHP process is separate from Apache so the scheduled job will not die in case a sysadmin restarts httpd.

share|improve this answer

yes you can use wget or curl

as direct commands or from a shell script

share|improve this answer

Note that the selected answer only works if you're interested in getting some html directly from a URL. If you need to wade through some UI stuff before you get to the page you need, I'd recommend running Selenium on a headless X server. I'm doing that for a project now, it works like a charm.

Hope this helps.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.