cron job execution for cpanel php script

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am trying to write a cron job, I created a php file which will run every Tuesday and Sunday.

To test this I created a cron job which runs every 5 minutes. I have written a mail function inside it, but it looks like the cron job is not working as I have also updated my email id for the notification purpose.

Here is my cron job code and my php code:

3   *   *   *   *   php -q /home/jxxjordan/public_html/ospb2b/mycrons/depature.php

My php code:

$to = 'routemate.tech@gmail.com';
$subject = 'Marriage Proposal';
$message = 'Hi Jane, will you marry me?'; 
$from = 'depature@routemate.in';

// Sending email
if(mail($to, $subject, $message)){
    echo 'Your mail has been sent successfully.';
} else{
    echo 'Unable to send email. Please try again.';
}

Is there anything wrong I am doing. I have got the cron job code from the in motion hosting forum.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.