Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/110695-solved-cronjob/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567907
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567937
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/110695-solved-cronjob/#findComment-567953
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.