I am trying to setup a cron job on my web hosting server. I want the php file to run every 15mins. Can some one tell me if I set it up right or not? Also, since there time is 3 hours behind me I want to use my own Php ini file with my local timezone.

    */15    *   *   *   *    php -c /home/username/public_html/php.ini /home/username/public_html/crontest.php

Is the Command correct?

Recommended Answers

Yes, commands looks valid.

Jump to Post

Don't see any obvious errors. Does the script work if you run it manually?

Jump to Post

All 7 Replies

Yes, commands looks valid.

Thanks for the reply.

I put this code in, but for some reason its not running the script. Below is my TEST CRON JOB SCRIPT

    $database_date = '2012-03-30 10:35:00';
    $today_date = date("Y-m-d H:i:s");

    if($today_date == $database_date) {
    $email = 'email@web.com';
        // Sending Email
        $to = $email;
        $message = '<html><head><title>Cron Job Practice</title></head><body><h3>TEXT HERE</h3><p>TEST HERE<br /><br />TEXT HERE</p></body></html>';
        $header = "MIME-Version: 1.0" . "\r\n";
        $header .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
        $header .= "From: Subject Name <email@link.org> \r\n";
        mail ($to,$subject,$message,$header);

is there something wrong with sending emails with cron? If you see an error please explain what I did wrong. Thanks so much for your time and help.

Don't see any obvious errors. Does the script work if you run it manually?

Yes, It works when I do it manually.
When I put in my Email for the "Cron Email" Section, It is showing me that the cron is running.


When the email is sent to me It reads

Content-type: text/html

Thats the only thing I see. Why is that? (Its as though it skipped over the If statment and went straight to the Header.


Nevermind, I see that its working now.

One more question: How do I get the HTML to work within the php mail?

Its alittle weird that its not working. When the codes look right. And I looked up other resources for more information
and they have written it the same way. Does it have something to do with the Cron?

(Sorry for all the question: As you can tell I am new to Cron Jobs)

Got it working! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.