0

I have a cron job the is run by the user called "taskmanager" every day and I need to reset a configuration every time.

the user taskmanager has NOPASSWD on /etc/sudoer

I also have a private repository where I made an RPM of my configuration. Whenever I ran the bash script manually the yum -y works flawlessly, however when the script is ran by cron the exit code is 1, manual execution's exit code returns 0.

    /usr/bin/sudo /usr/bin/yum -y reinstall --disablerepo="*" --enablerepo=codevault project-configuration
    echo $?
lloydm2
  • 23
  • 1
  • 3

1 Answers1

0

Your cronjob doesn;t have the environment set up correctly - probably a missing environment variable.

Tasks run in cronjobs do not pick up the environment of the user, just the permissions. So your user has permission to run the command (your sudoers file is probably fine), but some environment variable required for the command to run correctly is not set.

To figure out what, look at the output of cron - you probably have mail. Once you've identified the missing variable, you can set it in your cron file in various ways

Community
  • 1
  • 1
IBam
  • 10,114
  • 1
  • 24
  • 36