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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:46:36+00:00 2026-06-06T04:46:36+00:00

Using PHP I would like to be able to list root’s crontab. I am

  • 0

Using PHP I would like to be able to list root’s crontab.
I am able to run the following command as the Apache user from the command line and get the desired result:

sudo crontab -l

however, in my PHP I have the following command which does not work and returns an empty set:

exec('sudo crontab -l', $out);
print_r($out);

Is it environmental? Or permissions?

I have also tried shell_exec() system() and passthru()

Also, note that I have disabled SELinux and added Apache to the sudoers file so that it does not need to be prompted for a password.

  • 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-06T04:46:38+00:00Added an answer on June 6, 2026 at 4:46 am

    Solved: Even though I had set error reporting on, you must redirect the output of the command like so:

    exec('sudo crontab -l 2>&1', $out);
    var_dump($out);
    

    After setting this, I found the following error:

    sudo: sorry, you must have a tty to run sudo
    

    Following research of the issue, the resolution is to edit the sudoers file and comment out: #Default requiretty.

    http://www.zimbra.com/forums/installation/10553-solved-sudo-sorry-you-must-have-tty-run-sudo.html

    I apologize as I got further into this issue, it became less of a PHP issue and more of unix system question.

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

Sidebar

Related Questions

I would like to extract the GPS EXIF tag from pictures using php. I'm
Using Php I would like to extract the current Url of a page including
I would like to access a MySQL database using PHP. Can someone please explain
I have a jar file that I would like to execute using PHP, but
Assuming the input string +123-321+123 345 , using PHP's regex functions I would like
I would like to redirect all images to a showimage.php, using htaccess But if
I'm using a multi dimensional array in php, I would like to know how
I would like to do a site in PHP/MySQL using either Drupal/Joomla/Wordpress that allows
I have several web applications developed using PHP and would like to set these
I would like to be able to detect what country a visitor is from

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.