cronjob error

deltaned

Verified User
Joined
Jan 23, 2004
Messages
102
Hi,

An customer have an script on his site so he can check every 24hr some names and iff needit there will send mails out.

He make an cronjob but we get:
/bin/sh: line 1: /home/username/domains/userdomain.com/public_html/job.php: Permission denied

In his job.php he add:
chdir('/home/username/domains/userdomain.com/public_html');
<?
mysql_connect ("localhost", "user_sql", "user_pass");
mysql_select_db ("user_database");

function tekst ($id) {
return @mysql_result (mysql_query ("SELECT twee FROM teksten WHERE id='$id'"), 0, twee);
}
(and mutch more)

What can we do to run this script every 24 hours?
Tips are welcome!
 
make so:
Code:
0 0 * * * /usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php
 
Last edited:
directadmin.ru...

Read the post again and you'll see that deltaned's problem is that it doesn't run at all, not that he doesn't know how to set up cron jobs.

deltaned...

Have you tried running it from the cron job commands from the command line? Have you tried running the actual cron job from the command line?

If you don't have shell access to the server (and I'd bet you don't, based on the forum you're writing in), you'll probably have to be in touch with your hosting provider to have him/her help.

Jeff
 
I has understood from
/bin/sh: line 1: /home/username/domains/userdomain.com/public_html/job.php: Permission denied
That deltaned attempts to start this script as sh script, and script on php it is necessary to start through interpretator php, or in the beginning script it is necessary to paste #!/usr/local/bin/php And to establish chmod 755
 
so this is EXACTLY what i need to type in the command section ONLY:

Code:
#!/usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php
 
Pheonix said:
so this is EXACTLY what i need to type in the command section ONLY:

Code:
#!/usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php

No, thats a command but not for cron.

0 0 * * * /usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php

The piece in bold tells cron how often to run it, t run the script directly from command line you can use the line you posted without the #! - that is only for use at the top of pages ;)

Chris
 
but doesnt it let you set 0 0 * * * and stuff in the fields above? or do i just leave them all at the default *

also while your here :)

i want to run this cron job as well

Code:
(cd /home/pheonix/domains/lordsofthemist.com/tmp/jpcache/ ; rm * )

but am getting this error

Code:
rm: cannot remove `*': No such file or directory

the command i want to run is to clear that directory every certain amount of times. (yes that directory is correct and properly chmodded i just think i have a syntax error :S
 
Last edited:
works great now :)


what about the other cron job one to clear the directory? whats rong with it? (code posted above)
 
Last edited:
rm -r /path/to/directory

Once your confident it does what you want change it to:

rm -rf /path/to/directory

** DO NOT RUN "RM -RF /" OR ANY COMMAND LIKE THAT FROM THE ROOT DIR **

Chris
 
running this command

Code:
*	*	*/2	*	*	 rm -r /home/pheonix/domains/lordsofthemist.com/tmp/jpcache


i get this error:

Code:
rm: cannot remove `/home/pheonix/domains/lordsofthemist.com/tmp/jpcache': No such file or directory

what should i be putting instead?
 
Originally posted by Pheonix i get this error:

Code:
rm: cannot remove `/home/pheonix/domains/lordsofthemist.com/tmp/jpcache': [b]No such file or directory[/b]

what should i be putting instead?

Read the error..

ls /home/pheonix/domains/lordsofthemist.com/tmp/jpcache

output?

cd /home/pheonix/domains/lordsofthemist.com/tmp/
ls

do you see jpcache listed there?

Chris
 
ok... i have a script that randomly generates files in the folder jpcache that i want cleared every 2 days. i cant specify the file names as they are 32 digits long and randomly made with no file extension.... so what command in

/home/pheonix/domains/lordsofthemist.com/tmp/jpcache

do i run to clear that directory while not deleteing the folder jpcache so that the files may still generate there normally.

sorry for all the confusion.
 
Pheonix said:
ok... i have a script that randomly generates files in the folder jpcache that i want cleared every 2 days. i cant specify the file names as they are 32 digits long and randomly made with no file extension.... so what command in

/home/pheonix/domains/lordsofthemist.com/tmp/jpcache

do i run to clear that directory while not deleteing the folder jpcache so that the files may still generate there normally.

sorry for all the confusion.

rm -f /path/to/directory/*

Chris
 
Back
Top