Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
NDD Camp 2024

cron job problem

Status
Not open for further replies.

edpudol

Level 8
Legacy Platinum Member
Joined
Dec 26, 2004
Messages
1,031
Reaction score
0
I am trying to run a php script in my server using cron job, but I keep getting a Permission denied error.

the code is look like this /home/public_html/folder/script.php

I never tried to run cron job before, does anyone can help...
 

Dale Hubbard

Formerly 'aZooZa'
Legacy Exclusive Member
Joined
Jan 24, 2003
Messages
5,578
Reaction score
91
You need to tell the cron what program to invoke it with.

I don't know what interface you're using to run the job, but first off it needs to know when to run, and then the path to the executable that runs the command. An example in your case might be something like:

0 22 * * * /usr/bin/php -q /home/public_html/folder/script.php

The above will run the cron job at 22:00 each day.

Google for 'cron php'

Good luck!
 

sleddogrob

Level 3
Legacy Platinum Member
Joined
Apr 30, 2006
Messages
72
Reaction score
0
Sounds like you have the cron job set up correctly but your srcipt.php does not have the correct permissions. You need to do a chmod on the file script.php.

If you are using CPanel open file manager and locate the script you are trying to run. Click on your script file and then on the right side of the screen you will see change permissions. Click that and you will be allowed to set the permissions.

BE VERY CAREFULL CHANGING PERMISSIONS BECAUSE YOU WILL OPEN UP YOU SCRIPT FOR THE WHOLE WORLD!!!!
 

movil

Level 3
Legacy Platinum Member
Joined
Aug 25, 2005
Messages
67
Reaction score
0
If you have curl , you can mount it this way:

0 22 * * * curl \"http://yourdomain.com/script.php\"

This will execute the php like if you type it on the address bar of your browser. This way it\'s easy to log as well ( if you \'ve this script printing some report ):

0 22 * * * curl \"http://yourdomain.com/script.php\" >/path/to/your/file.txt 2>&1

Just an advice, the quotes are not meant to be escaped, remove the \\ . I\'m browsing his through a special browser.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
MariaBuy

Our Mods' Businesses

URL Shortener
UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom