ssh and cron jobs

ezkim0x

Senior member
Nov 25, 2004
320
0
0
i put this php code in absolute.php and uploaded to: domain.com/folder/

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>

and it returned:

/kunden/homepages/41/d171141329/htdocs/domain.com


i downloaded putty for windows.. and connected through ssh.

crontab -e

pressed the insert key and typed in

# daily reset stats
20 19 * * * php /kunden/homepages/41/d171141329/htdocs/domain.com/folder/reset.php

pressed esc and typed in :wq and enter

now when i type in crontab -l it lists it.. so it should be saved, and it will run that php script at 7:20 (this is just to test.. i'm changing to midnight "00 00" later)

but it doesn't run.. i'm positive the php file works cause when i goto manually into my browser it runs the code.. do you know what i'm doing wrong?
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
http://faq.1and1.com/scripting...orted/cron_jobs/6.html this is a faq on my hosts site.

the absolute path starts out with /homepages/xx/xxxxxxxx/ ..like everybodys should be the same.. so i tried it without /unden/ on the front too.

i've tried all these combinations:

# daily reset stats
20 19 * * * php /kunden/homepages/41/d171141329/htdocs/domain.com/folder/reset.php

# daily reset stats
20 19 * * * php /homepages/41/d171141329/htdocs/domain.com/folder/reset.php

# daily reset stats
20 19 * * * /kunden/homepages/41/d171141329/htdocs/domain.com/folder/reset.php

# daily reset stats
20 19 * * * /homepages/41/d171141329/htdocs/domain.com/folder/reset.php

also tried moving reset.php to domain.com/reset.php instead of /folder/reset.php
 
Aug 25, 2004
11,166
1
81
You need to find the absolute path to the php binary. For example:
/usr/local/bin/php
/usr/local/php5/bin/php

Also, the binaries for php4 and php5 (if your server has both) will be in different directories.

Example:

44 9 * * * /usr/local/php5/bin/php /home/gpb/domains/facebook.domain.com/blog/cron.php > /dev/null
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
u40796793:~ > whereis php
php: /usr/local/bin/php /usr/local/lib/php3.ini /usr/local/lib/php5.old /usr/local/lib/php /usr/local/lib/php.ini /usr/local/lib/php.ini-nourl

edit:

tried this..

# test cron
18 20 * * * /usr/local/bin/php /homepages/41/d171141329/resetcron.php

and

# test cron
21 20 * * * /usr/local/bin/php /homepages/41/d171141329/resetcron.php > /dev/null


 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
so my host won't help me, and aren't even replying to me since saturday.

the last thing they told me was this:

Thank you for contacting us.

The path to your cron job should look like this
/homepages/41/d171141329/. Just make sure that your cron job
folder does exist on the 1&1 webspace.

If you have any further questions please do not hesitate to contact us.

--
Sincerely,
Emelita Gultiano
Technical Support
1&1 Internet

and my reply.. which is still the case, and I can't figure it out.. if anybody can help me out I would appreciate it greatly. I've seriously been trying to get this setup for about a week now.

i moved the file to the main directory for when i login.

"/kunden/homepages/41/d171141329/htdocs/"

u40796793:~ > crontab -l
# test cron
40 * * * * /usr/local/bin/php /homepages/41/d171141329/resetcron.php

i tried this one.. and also every varation i could think of.. with /kunden/ without.. with /htdocs/ without.. .. tried just putting 'php' instead of '/user/local/bin/php' .. tried not putting php at all

and i just kept changing "40" to a minute ahead of the server time.. to test.. i'm positive that the php file works because if i access it via the web it runs the script fine.. but i can't get the cron job too.

Jon
 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Have you tried just executing the command '/usr/local/bin/php /homepages/41/d171141329/resetcron.php' while connected via ssh to test if the command itself will run? If the command won't run from the command line, it won't run from cron. Running it through the web server doesn't necessarily mean it will run through the command-line php interpreter.
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
not sure how to try an execute it.. just "exec /usr/local/bin/php /homepages/41/d171141329/resetcron.php" ?

i tried that and putty closed out.
 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Originally posted by: ezkim0x
not sure how to try an execute it.. just "exec /usr/local/bin/php /homepages/41/d171141329/resetcron.php" ?

i tried that and putty closed out.

Leave off the "exec". php is a command, just like ls or cp.
 
Aug 25, 2004
11,166
1
81
To start off, ssh into your server and cd to the directory where you have resetcron.php. Type:
> php resetcron.php

If that runs AND does what it's supposed to, take it to the next step:
> php /homepages/41/d171141329/resetcron.php

If that works, try:
> /usr/local/bin/php /homepages/41/d171141329/resetcron.php

If the last line works as expected, you can use it in your crontab.
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
php resetcron.php worked fine.

but the next line didn't.. but since php resetcron.php worked through the cmd line in ssh then it should work for the crontab right? .. i'm just not getting the location right.

-------------------------

u40796793:~ > php resetcron.php
X-Powered-By: PHP/4.4.7
Content-type: text/html

u40796793:~ > php /homepages/41/d171141329/resetcron.php
Status: 404
X-Powered-By: PHP/4.4.7
Content-type: text/html

No input file specified.
u40796793:~ >
 

Hyperblaze

Lifer
May 31, 2001
10,028
1
81
Originally posted by: ezkim0x
php resetcron.php worked fine.

but the next line didn't.. but since php resetcron.php worked through the cmd line in ssh then it should work for the crontab right? .. i'm just not getting the location right.

-------------------------

u40796793:~ > php resetcron.php
X-Powered-By: PHP/4.4.7
Content-type: text/html

u40796793:~ > php /homepages/41/d171141329/resetcron.php
Status: 404
X-Powered-By: PHP/4.4.7
Content-type: text/html

No input file specified.
u40796793:~ >

correct
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
do you have any ideas?

i just tried making my crontab

# test
39 * * * * php resetcron.php as well.. since the other locations i tried weren't working.

but that didn't work either.. I wish 1and1 would reply to me. that's seriously the only reason i upgraded my account.. and I don't feel like going through the process of getting a new host and transfering all my stuff.
 
Aug 25, 2004
11,166
1
81
Originally posted by: ezkim0x
# test
39 * * * * php resetcron.php

this won't work because cron won't know where resetcron.php is.

cd to the directory where resetcron.php is and type:
> pwd

What does it say?
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
/kunden/homepages/41/d171141329/htdocs/

i've tried that as well though.. in a mail i sent my host and asked them what to use giving the example that I used "/kunden/homepages/41/d171141329/htdocs/"

they told me to use: /homepages/41/d171141329/

which is what I tried, and it didn't work.
 
Aug 25, 2004
11,166
1
81
At the command prompt, type:

> /usr/local/bin/php /kunden/homepages/41/d171141329/htdocs/resetcron.php

If that works, stick in your crontab and ignore what your host says.
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
u40796793:~ > /usr/local/bin/php /kunden/homepages/41/d171141329/htdocs/resetcron.php
X-Powered-By: PHP/4.4.7
Content-type: text/html

u40796793:~ >

worked fine in command prompt... but then when I put the same code int he crontab it doesn't run.

u40796793:~ > crontab -e
crontab: installing new crontab
u40796793:~ > crontab -l
# test cron
32 * * * * /usr/local/bin/php /kunden/homepages/41/d171141329/htdocs/resetcron.php


EDIT:

I just found this http://www.alexschultz.co.uk/w...1/my_first_cron_j.html

read adams post.. the second to last.. his problem is almost the same as mine.. I wonder if it's just something to do with our host.
 
Aug 25, 2004
11,166
1
81
Try adding " date +%H%M > $HOME/test.txt" to your crontab. Set it to run in a few minutes.

When (or IF) cron runs this job, it should make a file called test.txt in your home directory. Typing:
> cd
> cat test.txt

should give you the time in HHMM format.

If this does not work, it means that your host is fucked and you need to find a new one.
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
u40796793:~ > crontab -e
crontab: installing new crontab
u40796793:~ > date
Fri Feb 29 06:26:59 EST 2008
u40796793:~ > crontab -l
# test cron
28 * * * * date +%H%M > $HOME/test.txt
u40796793:~ > date
Fri Feb 29 06:28:09 EST 2008
u40796793:~ > cd
u40796793:~ > cat test.txt
cat: test.txt: No such file or directory

I looked in my ftp directory and it didn't show up there.. if I just do it directly through the cmd line it does create the file though.. so I guess it is something fucked up with my host and their cronjobs.

u40796793:~ > date +%H%M > $HOME/test.txt
u40796793:~ > cat test.txt
0633
u40796793:~ >


 

ultimatebob

Lifer
Jul 1, 2001
25,135
2,445
126
Perhaps the host doesn't have the cron deamon running. Try running a ps -ef | grep crond and see if it's there.
 

ezkim0x

Senior member
Nov 25, 2004
320
0
0
u40796793:~ > ps -ef | grep crond
Unknown HZ value! (37) Assume 100.
u407967 7757 7053 0 03:25 ttyp1 00:00:00 grep crond
u40796793:~ >

that's what it gave me.. not sure what it means.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |