Solved

CronTab to execute PHP code

Posted on 2004-10-11
3
860 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 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