Solved

CronTab to execute PHP code

Posted on 2004-10-11
3
847 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress Query 1 31
creating 2 user ID's 5 24
Modify PHP Code on the Fly? 8 38
resizeing PHP image 2 21
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now