AnsweredAssumed Answered

Switch to other User and execute commands

Question asked by Srujan_Pathuri_9871 on Mar 28, 2018
Latest reply on Apr 3, 2018 by Andrew_Garland_7890
Hello All,

I would like to have some part of commands to be executed by a different user other than the user that it is already been logged into. The following command is placed in the PROCESS tab of UNIX job.

sudo su - <otherUser> bash -c 'service stop all' 

When I execute the job, it is not showing up any logs in report window, I guess it is looking for password to switch to other user.
However, I want to switch to the other user without password and also it would be good if I am not advised to modify /etc/sudoers file. :)

Note: Please look at the following, how I was able to switch to other user manually without entering password and then executed "service stop all" command.  

[user1@us5np309 ~]$ sudo su - user2
[user2@us5np309 ~]$ service stop all

Am I missing out something simple here. Please help me with this.