Cronjob Problem Plzzz Help


#1

I have a php file that has a simple code to send goodmorning email to a mail id. the file sends goodmorning mail whenever i visit it through web browser. now i want to put it in cronjob so that it sends goodmorning mail every 30 minutes. i have written

30 * * * * /usr/local/bin/php /home/username/domain.com/send.php

as my cronjob entry. yet it is not sending me any mail. i have even added
#!/usr/local/bin/php -q

in my php file. am not getting any error mail also. plz help


#2

That other thread you posted in did have a suggestion to try the following syntax:

If you’re using the panel to enter the cronjob, you don’t need the 30 * * * *, so I’m hoping you did this via crontab -e on the command line.

-Scott


#3

sorry 2 bother u again but am using crontab -e command. i don’t have access to anything else. am writing

30 * * * * /usr/bin/curl -s -o /dev/null http://www.ashishtiwari.com/send.php

in my crontab. the file http://www.ashishtiwari.com/send.php works fine when i execute it using browser or using command line but whn i write this in crontab, it is not working. plzzzz help me…


#4

30 * * * * curl -s -O http://www.ashishtiwari.com/send.php


#5

Thanx for the reply but this one also didn’t work… what should i do ?


#6

Being nosy, I typed it into my browser and got a “Mission Accomplished” page.

Try:
30 * * * * /usr/bin/curl http://www.ashishtiwari.com/send.php

It may dump results in your mailbox, but at least you’ll know it’s working. I tried it from command line, and it does work. Make sure to use full path for curl.

-Scott


#7

thanx 4 the reply, yes i got the mail i.e. output of the send.php as am a beginer , i would be thankfull if you could plz let me know how to find out “full path for curl” ? & am not getting any mails in my mailbox


#8

Full path is /usr/bin/curl
To find out, type ‘which curl’ on the command line.

-Scott


#9

Thanx scott for that reply but the problem remains the same now my entry in crontab looks like

30 * * * * /usr/bin/curl http://www.ashishtiwari.com/send.php

but it still won’t work. what else can i try ?


#10

as suggested futher up the thread, it should be

30 * * * * /usr/bin/curl -s -o /dev/null http://www.ashishtiwari.com/send.php
Alternatively in the panel, go to cron jobs, and enter

/usr/bin/curl -s -o /dev/null http://www.ashishtiwari.com/send.php
If that doesn’t work, it’s likely to be your code that’s broken… try attaching debug vars, catching errors, and emailing the result to yourself via the mail() function (pass or fail with errors).

Cheers,
Karl

web design, development & seo by DigitalVibe


#11
<?php $mail = '****@****.com'; $sendto = '*****@****.com'; $msg = "Good Morning"; if(mail($sendto, $subject, $msg, "From: $mail")) { echo "Mission Accomplishd"; } else { echo"OOPS Application made a POO POO"; } ?>

this is the code written in send.php file


#12

I presume there’s more in the send.php file?

  • Subject has no value according to that code snippet.

  • I meaning that if there was code at work somewhere before it sends the mail, then to trap errors in that block of code and email you a report saying there was a problem.

  • An “echo” is useless if you’re running a cron job like that because you’re never going to see the resulting success/fail message… it needs to mail() you the error.

Cheers,
Karl

web design, development & seo by DigitalVibe


#13

http://wiki.dreamhost.com/Crontab

*/30 * * * * /usr/bin/curl -s http://domain.com/send.php 1>&2 &>/dev/null ________________________
[color=#00CC00] _ _| _ _ _ _|_ _ (_|_\|<(_||_)(_|(_| |(/_ | [/color]


#14

My example should be working already though (i use it on several domains already), which is why i’m suspecting it might be a php code error.

All we know is that “it doesn’t work”. We don’t know any more, so hopefully if the eu can get some sort of debug script together, we can see why it’s failing.

Cheers,
Karl

web design, development & seo by DigitalVibe


#15

I concur. There’s nothing wrong with digital’s cronjob.

These all work via cron as well:

30 * * * * curl -s -O http://dom.com/path/file.php ~ Will run and NOT bug you with a cron msg mail : See here

30 * * * * curl -s http://dom.com/path/file.php ~ Will run AND WILL bug you with a cron msg mail

30 * * * * curl http://dom.com/path/file.php ~ Will run AND WILL bug you with a cron msg mail

I find /usr/bin/ directives are unnecessary when calling curl.


#16

Maybe the problem is occurring because of a bad php configuration or handler on the domain.com, maybe an old php, maybe an old apache 1.3 handler.

execute it directly with php5:

30 * * * * /dh/cgi-system/php5.cgi /home/user/domain.com/send.php 1>&2 &>/dev/null _____
[color=#00CC00] _ _| _ _ _ _|_ _ (_|_\|<(_||_)(_|(_| |(/_ | [/color]
:~


#17

believe me tis is the only code written in my send.php file & it works fine. am a beginer & would appritiate if you can repair, edit or modify the code of send.php & suggest me the entry in crontab file


#18

I used your send.php (with my email address) and inserted this line:

30 * * * * curl -s -O http://www.mydomain.com/send.php

I received an email at 30 minutes after the hour, every hour.

I don’t know what else to tell you mate. Maybe you’re not waiting long enough to witness the response of the cronjob before considering it failed and changing it? If it’s impatience getting in the way, change 30 to */5 for a quicker test result (5 minutes).

Remember to change it back to 30 or */30 later tho.


#19

30 * * * * /usr/bin/curl -s -o /dev/null http://www.ashishtiwari.com/send.php
30 * * * * /usr/bin/curl -s -O http://www.ashishtiwari.com/path/send.php
30 * * * * /usr/bin/curl -s http://www.ashishtiwari.com/path/send.php
30 * * * * /usr/bin/curl http://www.ashishtiwari.com/path/send.php
30 * * * * curl -s -O http://www.ashishtiwari.com/send.php
30 * * * * /usr/bin/curl -s -O http://www.ashishtiwari.com/send.php

none of them is working. even replacing 30 with 5 is also not working. the crontab entries are given above & the php code am using is given above.

is there any other problem with my setup or any permission is required?


#20

I believe you’ll need to ask support to take a look at the server config for you. Give them as much information as you can, even link to this thread.

Do let us know how you get on, this is an interesting problem.