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

  • Home
  • SEARCH
  • 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 6221171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:05:10+00:00 2026-05-24T08:05:10+00:00

I am trying to replace the crontab using a new crontab stored at /tmp/crontab.txt.

  • 0

I am trying to replace the crontab using a new crontab stored at /tmp/crontab.txt.

  $output = '';
  $output .= "Existing Crontab contents:<br>";
  $output .= shell_exec('crontab -l');

  $output .= "<br>new contents:<br>";
  $output .= file_get_contents('/tmp/crontab.txt');

  $output .= "<br>Result of import:<br>";
  $output .= shell_exec('crontab /tmp/crontab.txt');
  $output .= shell_exec('crontab -l');
  echo $output;

The output is:

Existing Crontab contents:
1 2 3 4 5 existing
new contents:
* * * * * echo 'test'
Result of import:
1 2 3 4 5 existing 

You can see the import does not work and does not show an error.

Apache is running as ‘nobody’. I have tried crontab -u nobody /tmp/crontab.txt as root and it works.

Is this a permissions issue? If so, why is php (running as nobody) unable to update it’s own cron? How do I get around this?

Thanks

  • 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-05-24T08:05:10+00:00Added an answer on May 24, 2026 at 8:05 am

    Try changing your import line to this:

    $output .= shell_exec('crontab /tmp/crontab.txt 2>&1');
    

    that’ll redirect stderr to stdout and let PHP catch any error message cron’s spitting out.

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

Sidebar

Related Questions

I'm trying to replace each , in the current file by a new line:
I'm trying to replace every multiline import inside a Python source file.. So, the
I am trying to replace 1234567890123456 with ************3456 with the following code: Regex.Replace(xml,@\b\d{13,16}\b, string.Concat(new
I am trying to replace a character - say ; - with a new
im trying to replace a remove unnessary new lines with preg-replace but my regex
I am trying to replace the global operator new and delete. In Linux this
I've been trying to replace to following string using the following... var r =
I am trying to replace a node using ReplaceWith(), but noticed that it results
I am trying to replace a sentence in .config file using powershell. ${c:Web.config} =
I'm trying to replace \ (backslash doouble quote) by ' (quote) using sed. sed

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.