raklos
raklos

Reputation: 28545

How do I hit a URL daily with PHP or Perl as a scheduled task in Plesk?

I am using shared hosting on Windows. I need to run some code that will basically just hit a URL on my .NET site once a day.

I'm using Plesk. I have seen that I can create scheduled tasks in Plesk, but when I asked my hosting service provider they said I can only execute PHP or Perl scripts (and not Windows executables).

I have zero experience in PHP and Perl. How can I do this using either Perl or PHP? Are there any gotchas? Do i need to set anything else up on my server to run these scripts, or is it just a case of dropping these .php or .perl files somewhere?

Upvotes: 2

Views: 1320

Answers (1)

Lix
Lix

Reputation: 47986

<?php

  file_get_contents('http://yoururl.com');
  exit();

?>

That will make a request to 'http://yoururl.com'. If you are not concerned with the response then this is the way to go. All you have to make sure is that your server can execute php code - I think it's pretty safe to say that most servers today are able to do that. Especially if its shared hosting.

You can place this in a cron job though your plesk control panel.

If you are allowed to execute system processes, you might also be able to get away with placing this command as the cronjob :

wget -O - 'http://yoururl.com'

From the wget man pages -

Wget - The non-interactive network downloader.
Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies...

Upvotes: 5

Related Questions