Ismael
Ismael

Reputation: 11

Setting up a cron Job

Please I am new to cron jobs and only heard of it recently.

The thing is I am trying to send a message to myself via a phpscript.

I need the cron job to read the php cript and send the appropriate message.

here is the php self mailer I have in place.

<?php
    $recipient = "*******@gmail.com";
    $subject = "Flight Status";
    $body = "Flight has just landed.";
    if(mail($recipient, $subject, $body))
    {
        echo("<p>Message successfully sent</p>");
    }
    else
    {
        echo("<p>Message Delivery failed </p>");
    }
?>

Upvotes: 0

Views: 270

Answers (2)

xurei
xurei

Reputation: 1086

Sending email through phone is complicated, as you need a smtp server set up. A better solution would be to send yourself a message via a chat application.

I personally use nimrod for this : https://www.nimrod-messenger.io It's messenger only but other chat systems are planned.

Upvotes: 0

Jasonw
Jasonw

Reputation: 5064

you can read the manual for cron with man 5 crontab. It contain example as well. for example,

# run at 2:15pm on the first of every month -- output mailed to paul

15 14 1 * * $HOME/bin/flight.php

Upvotes: 1

Related Questions