Search code examples
shellautosys

how to check using which user shell is being executed


I have a korn shell script which is being called from an Autosys job scheduler. However i wanted to know using which user name (from the scheduler) my script is being executed so that i can call related environment files inside my script.

Example:

autosys job user = test

environment = QA

In this scenario how can i capture user test inside my shell? i.e. who is calling the shell.

I tried using ps -ef however it is listing all the details and i am not good at autosys commands


Solution

  • Not sure about your complete requirement but you could use whoami inside your code before running the job. Also from outside(console) once job is kicked off you could use ps -ef | grep your_job(or look for some keyword which your job will have.)

    Converted my commented(answer) to an answer here.