The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Noob, script formatting query benjo Shell Programming and Scripting 2 03-03-2008 04:37 AM
Why does my script not work? (Noob Alert) bronkeydain Shell Programming and Scripting 4 02-21-2008 01:45 PM
Crontab a Script moutaz1983 Shell Programming and Scripting 6 01-16-2008 07:35 AM
noob. need help to create a script. aron Shell Programming and Scripting 1 07-09-2007 05:13 PM
how can i use crontab in a script? DebianJ Shell Programming and Scripting 1 05-05-2005 06:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-25-2007
Registered User
 

Join Date: Apr 2007
Posts: 7
Using PHP script with crontab (NOOB)

Hi, I am trying to use a PHP script as a test for a cron job.

My crontab is 1 line:

30 * * * * /home/www/inc/crontab.php

if I test the file through the browser (ie. http://www.domain.com/inc/crontab.php), the PHP script works -- so there is nothing wrong with the PHP script itself or the path.

I aked my hosting admin for assistance and the error he keeps getting is:

/bin/sh: line 1: /home/www/inc/crontab.php: Permission denied

What permission do I need to set to get it to work???
Reply With Quote
Forum Sponsor
  #2  
Old 04-25-2007
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,469
What about this (adjust path to php executable below)?

30 * * * * /usr/bin/php /home/www/inc/crontab.php

Note that your host may not necessarily have the php executable installed if it is just meant to run as a module to Apache. Only you (or your host admin) will know how the PHP is configured. In that case, you will not be able to run PHP scripts on the command line.

By the way the following works for me:

a.php:

#!/usr/bin/php
<?php phpinfo() ?>

chmod +x a.php
./a.php

So you probably may do it too.
Reply With Quote
  #3  
Old 04-25-2007
Registered User
 

Join Date: Apr 2007
Posts: 7
what does:



chmod +x a.php
./a.php



do?
Reply With Quote
  #4  
Old 04-26-2007
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,469
Make the script executable on a Unix system, and then execute it on the command line.
Reply With Quote
  #5  
Old 04-26-2007
Registered User
 

Join Date: Jun 2006
Location: Las Vegas, NV
Posts: 104
30 * * * * wget -O /dev/null http://www.domain.com/inc/crontab.php

could always try something like this...
Reply With Quote
  #6  
Old 04-26-2007
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,469
Quote:
Originally Posted by kingdbag
30 * * * * wget -O /dev/null http://www.domain.com/inc/crontab.php

could always try something like this...
The OP said "Hi, I am trying to use a PHP script as a test for a cron job.", not accessing a PHP script (or other URLs via HTTP(S)) on a remote server in a cron job.

They are totally different things. Usually, what a cron job does is not something that should be accessible on the public Internet. If someone use your scheme to run a cron job with a http://localhost/... URL, that means the script is there for everyone on the Internet to execute (provided he/she knows the URL), no matter you like it or not.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0