Solved

CronTab to execute PHP code

Posted on 2004-10-11
3
857 Views
Last Modified: 2012-06-27
Hi,

I have a status.php webpage that needs executing via a cronjob every 60 seconds, I use directadmin as the control panel, how do I enter the cronjob code to load that webpage every 60 seconds so it can do its job ?

Cheers
0
Comment
Question by:MirageSF
3 Comments
 
LVL 12

Expert Comment

by:minichicken
ID: 12275874
If you can set the time schedure in directadmin with a interface, then all you need is to enter the command which is something like this:

GET my_path/status.php

0
 
LVL 1

Accepted Solution

by:
gportal earned 50 total points
ID: 12351979
I'm not greatly up on DirectAdmin, so forgive me if I'm wrong...!

Set the mins, hours, days, months, etc, to * each,

You'll then need to enter the location of the php parser, and the location of the script into the Command box, like such:

/usr/bin/php /home/gportal/public_html/status.php

OR, if you don't want the mails being sent to you each time it outputs, try:

/usr/bin/php /home/gportal/public_html/status.php >> /dev/null 2>&1

Finally, an alternative is to add the php parser shebang to the top line of your script, permission it as an executable, and run it on its own right...

add: #!/usr/bin/php as line 1,

cron as: /home/gportal/public_html/status.php >> /dev/null 2>&1

If i'm waaaaaay of with the Direct Admin thing, let me know, and I may have a poke at it! :D
0
 
LVL 5

Expert Comment

by:crimson117
ID: 12377598
if you can put your php file on a webserver, put this command in your crontab:

lynx -dump http://www.yoursite.com/yourphpfile.php


Lynx is a text-based web browser.  The -dump option will dump the output of the php page to the standard output, so cron can do what you want with it (perhaps email it to the owner of the cron job?)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question