The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 07:37 AM
Why does my script not work? (Noob Alert) bronkeydain Shell Programming and Scripting 4 02-21-2008 04:45 PM
Crontab a Script moutaz1983 Shell Programming and Scripting 6 01-16-2008 10:35 AM
noob. need help to create a script. aron Shell Programming and Scripting 1 07-09-2007 08:13 PM
how can i use crontab in a script? DebianJ Shell Programming and Scripting 1 05-05-2005 09:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-25-2007
Bobafart Bobafart is offline
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???
  #2 (permalink)  
Old 04-25-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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.
  #3 (permalink)  
Old 04-25-2007
Bobafart Bobafart is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 7
what does:



chmod +x a.php
./a.php



do?
  #4 (permalink)  
Old 04-26-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Make the script executable on a Unix system, and then execute it on the command line.
  #5 (permalink)  
Old 04-26-2007
kingdbag kingdbag is offline
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...
  #6 (permalink)  
Old 04-26-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0