View Full Version : cronjob error
deltaned
05-08-2004, 02:30 AM
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!
directadmin.ru
05-08-2004, 07:14 AM
make so:
0 0 * * * /usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php
nobaloney
05-08-2004, 08:12 AM
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
directadmin.ru
05-08-2004, 08:32 AM
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
Pheonix
05-15-2004, 08:25 PM
so this is EXACTLY what i need to type in the command section ONLY:
#!/usr/local/bin/php -f /home/username/domains/userdomain.com/public_html/job.php
ProWebUK
05-16-2004, 02:55 AM
Originally posted by Pheonix
so this is EXACTLY what i need to type in the command section ONLY:
#!/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
Pheonix
05-16-2004, 10:48 AM
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
(cd /home/pheonix/domains/lordsofthemist.com/tmp/jpcache/ ; rm * )
but am getting this error
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
DirectAdmin Support
05-16-2004, 10:52 AM
set the minute to 0, the hour to 0 and the rest to *.
John
Pheonix
05-16-2004, 07:46 PM
works great now :)
what about the other cron job one to clear the directory? whats rong with it? (code posted above)
ProWebUK
05-17-2004, 06:17 AM
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
Pheonix
05-17-2004, 04:04 PM
running this command
* * */2 * * rm -r /home/pheonix/domains/lordsofthemist.com/tmp/jpcache
i get this error:
rm: cannot remove `/home/pheonix/domains/lordsofthemist.com/tmp/jpcache': No such file or directory
what should i be putting instead?
ProWebUK
05-17-2004, 04:06 PM
Originally posted by Pheonix i get this error:
rm: cannot remove `/home/pheonix/domains/lordsofthemist.com/tmp/jpcache': No such file or directory
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
Pheonix
05-17-2004, 06:01 PM
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.
ProWebUK
05-17-2004, 06:35 PM
Originally posted by Pheonix
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
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.