mmarif4u Posted June 18, 2008 Share Posted June 18, 2008 hi to all. I run a script through cron tab in cpanel, but it did not send me email. command is: /usr/bin/php /home/useraccount/public_html/mail.php setting is: Minutes hour day month weekday */5 2 18 6 3 Any ideas,whats wrong in this command or time. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/ Share on other sites More sharing options...
bluejay002 Posted June 18, 2008 Share Posted June 18, 2008 have you tried running that script? maybe the script itself has the error. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567903 Share on other sites More sharing options...
mmarif4u Posted June 18, 2008 Author Share Posted June 18, 2008 just run the script, it works. code is: <?php $to = "mmarif4u@yahoo.com"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?. this cron test."; if(mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> this is just for test for cron job. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567907 Share on other sites More sharing options...
bluejay002 Posted June 18, 2008 Share Posted June 18, 2008 was the cronjob running? if it does... what does it displays? Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567915 Share on other sites More sharing options...
mmarif4u Posted June 18, 2008 Author Share Posted June 18, 2008 Sorry i cant understand. can you explain what you mean by 'was the cronjob running?' and 'what does it displays?' Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567922 Share on other sites More sharing options...
bluejay002 Posted June 18, 2008 Share Posted June 18, 2008 i mean... i was thinking that the reason that you were not able to receive the mails is because the cronjob for your script did not run. i dont know though since i haven't used cpanel for cronjobs. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567929 Share on other sites More sharing options...
mmarif4u Posted June 18, 2008 Author Share Posted June 18, 2008 yeh,i setup everything there.As i post in the 1st post about the command an time. i am curious about the command. maybe its not running because some thing is missing or not complete. OR may the php directory will be like: /usr/local/bin/php Just add local in it. any ideas now. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567937 Share on other sites More sharing options...
mmarif4u Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks guys. i solved it. its working fine now. for users who may want to use it in future, can read what i did. IN the command line put this: /usr/local/bin/php /home/useraccount/public_html/mail.php /usr/local/bin/php: works for executing the script as PHP file.its in linux usr and bin direcotry.u can check if u r using LINUX. useraccount: is your username for cpanel. mail.php: is your mail script name,Or whatever you want to execute. public_html: This is main directory where all your files will be(can access through FTP).You can make another dir also and put your script there,then run it like: for example dir is mmarif4u /usr/local/bin/php /home/useraccount/public_html/mmarif4u/mail.php Now setting the time,it depends on your needs.That when you want cron to execute your script. for example: * * * * * script will run every minute. 0 0 * * * script will run at midnight every night. Also you can set more timings,depends on the needs. I wrote details here,that maybe it will help someone here. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567953 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.