Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8872013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:07:18+00:00 2026-06-14T18:07:18+00:00

I have a cron set to run a php file but for some reason

  • 0

I have a cron set to run a php file but for some reason it doesn’t work when the time comes. I can manually call same file in terminal and it works fine. No error message as well.

Note: There are many more jobs set for different folder&files and they all work fine. Permissions are same as well.

Thanks

CRON

30 2 * * 1,2,3,4,5 php /var/www/html/cronjob/update-db.php

PERMISSIONS

drwxr-xr-x  2 root   root      4096 Nov 20 10:17 cronjob

-rwxr-xr-x 1 root root 5808 Nov 21 17:21 update-db.php
  • conn.php is being used by many other cronjobs and works fine.
  • this code works fine when I call run it in terminal.
  • every other cronjob works fine apart from this.

CODE

require_once "/var/www/html/dbfolder/conn.php";


function write_log($message)
{
    $filename = 'update-sis-assessment-column-log.txt';

    if (file_exists($filename))
    {
        $handle = fopen($filename, 'a');
    }
    else
    {
        $handle = fopen($filename, 'w');
        //chmod($filename, 0644);
    }

    fwrite($handle, $message . "\r\n\r\n");
    fclose($handle);

    exit;
}

if (connectDB() === true)
{
    $query = "SELECT.......";
    $rcset = mysql_query($query);

    $terms = null;

    if (@mysql_num_rows($rcset) > 0)
    {
        while ($records = mysql_fetch_array($rcset))
        {
            if (ctype_digit($records['Term']))
            {
                $terms .= "'" . substr($records['Term'], 0, 4) . "-01', ";
            }
        }

        $terms = substr($terms, 0, -2);
    }

    write_log('DONE : ' . $terms);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:07:20+00:00Added an answer on June 14, 2026 at 6:07 pm

    make sure that the php executable is in your path OR put the full path to php in the cron job like

    30 2 * * 1,2,3,4,5 /usr/bin/php /var/www/html/cronjob/update-db.php 
    

    if you are not sure where php is located you can run

    which php
    

    to get the path

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following php code set to run as a CRON job. It
I have a cron job set up to run testemail.php. This works fine, every
I have set up a php file to run that just echos hello. <?php
I have several PHP files to be run by cron. I set up the
I have a php script run as a cron job that executes a set
I have a CRON job php script that I just set up not too
If I have a cron job that run every 10 minutes and for some
Im new to this.I have a cron file called xml.php and i want to
I have a php script that triggers some magento actions, and I set it
I have some python scripts that run on a daily basis in cron. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.