I have a web page at http://mydomain.com/process/2909

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 = 'http://mydomain.com/process/2909';
        $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?

  • 3
    0 2 * * * /usr/bin/wget --quiet --output-document=/dev/null http://mydomain.com/process/2909 # get page at 2am, do not save output, be quiet
    – L.R.
    Mar 4, 2010 at 20:20

3 Answers 3


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 "mydomain.com" 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.


yes you can use wget or curl

as direct commands or from a shell script


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.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .