Why sudo included in the cron job is not working as expected in Red Hat Enterprise Linux 7 ?

Solution Unverified - Updated -

Issue

  • Why sudo included in the cron job is not working as expected in Red Hat Enterprise Linux 7 ?

    Example: Cron job configured for a non root user

    5 15 * * *  sudo docker exec  rhel7 sh -c "ps aux"  
    

    The following error occurs in cron job including sudo:

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

Environment

  • Red Hat Enterprise Linux 7
  • Sudo configured for non root users

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In