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 8706781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:42:04+00:00 2026-06-13T03:42:04+00:00

I have a cronjob that get’s updated when a (administrative) user sets a date.

  • 0

I have a cronjob that get’s updated when a (administrative) user sets a date. The cronjob is set correctly, because it shows like this in the cronjob list (on cPanel):

lynx -source http://www.example.com/dynam_code/autoscripts/expenseClaims.php?do=notify&date=1350252000&final=1350338400

This is the cronjob creation script:

$output = shell_exec('crontab -l');
$jobs = explode(PHP_EOL,$output);
$minute = '00';
$hour = '09';
$day = date('j',strtotime($_GET['reminder']));
$month = date('n',strtotime($_GET['reminder']));

for($i = 0; $i < count($jobs); $i++) {
    if(strpos($jobs[$i],'http://intra.vceza.com/dynam_code/autoscripts/expenseClaims.php?do=notify') !== false)
        $jobs[$i] = $minute.' '.$hour.' '.$day.' '.$month.' * lynx -source http://intra.vceza.com/dynam_code/autoscripts/expenseClaims.php?do=notify&date='.strtotime($_GET['done']).'&final='.strtotime($_GET['approved']);
    }
    foreach($jobs as $key => $value) { 
        if($value == "") { 
            unset($jobs[$key]); 
        } 
    } 
    $jobs = array_values($jobs); 

    $jobs[] = "";
    $output = implode(PHP_EOL,$jobs);
    file_put_contents('/tmp/crontab.txt', $output);
    exec('crontab /tmp/crontab.txt',$output,$return);

This cronjob triggers a mailing script that sends a mail to the whole company based on those dates. When the script runs automatically, it shows all the dates as 1 January 1970. But, when I copy the path to that PHP file from the cron job and run it, it sends out the correct dates.

Here is the script that grabs the date and sends the mail:

if($_GET['do'] == 'notify') {
    $time = $_GET['date'];
    $day = date('l',$time);
    $date = date('j F Y',$time);
    $final = date('j F Y',$_GET['final']);
    $to = 'people@example.com';
    $str = "Expense Claims";

    $html_data = '<html><head><title>'.$str.'</title></head><body style="font-family:Calibri, Arial; font-size:15px">Good day all,<br/><br/>Please take note that all Expense Claim should be completed on the intraweb by ' . $day . ' morning <b>' . $date . ' before 9am.</b><br/><br/>All supervisors should approve claims by Friday morning <b>' . $final . ' before 9am.</b> <br/><br/>All slips and supporting documents should be handed in by Friday morning <b>' . $final . ' before 9am</b>. Bear in mind that it is the sole responsibility of the claimee to hand in his/her slips or supporting documents.<br/><br/><span style="color:red">Please take note that Expense Claims will only reach the Finance Department if <b>submitted and approved on time.</b> Claims not submitted or approved on time will only be processed in the following month.</span><br /><br/>Kind regards,<br/>JD</body></html>';

    $mime = new MIME_mail("John Doe <jd@example.com>", $to, $str);
    $mime->fattach($path,"",OCTET,BASE64,ATTACH);
    $mime->attach($html_data,$str, HTML, BASE64);
    $mime->send_mail();
}

I have no idea what the issue is, I’ve tried looking through the code. Like I said, if I run it manually it works. If the cronjob runs it, it doesn’t.

  • 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-13T03:42:06+00:00Added an answer on June 13, 2026 at 3:42 am

    Your crontab entry contains a ‘&’ after do=notify. If you use a ‘&’ in a command in a cron job (or a *nix shell for that matter), it means that the part before the & will be executed in the background. Therefore, only the ‘lynx -source http://www.example.com/dynam_code/autoscripts/expenseClaims.php?do=notify‘ part is executed. You need to quote the url, so the command will look like this:

    lynx -source 'http://www.example.com/dynam_code/autoscripts/expenseClaims.php?do=notify&date=1350252000&final=1350338400'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple user signup form with a checkbox that lets users get
We have a database that gets updated everyday at midnight with a cronjob, we
I have a cronjob calling a shell script. Inside that shell script and I
I have a CRON job php script that I just set up not too
I have a cronjob that runs every hours and parse 150,000+ records. Each record
I have a cron job scrape.sh that look like this: #!/bin/bash touch rage cd
I have a cronjob that summarize browser statistics. This cronjob loads data and then
/bin/sh: /Users/alex/filename.py: No such file or directory I have set a cronjob and it
If I have a cron job that run every 10 minutes and for some
I have a servlet running on GAE and I have a cron job that

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.