Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine what cron user is running the script 1

Status
Not open for further replies.

ls62

Programmer
Joined
Oct 15, 2001
Messages
179
Location
US
Hi,

I'm running a script from cron which uses the 'logname' command, but does not work when the job is executed from cron, it does work fine from command line. When a script is run from cron... how can I determine what cron user is executing the script.

Anyone know?

Thanks

LEE
 
Have the script "touch" a new file (/tmp/cron.$$ say) and have it check the owner of the file, and display the owner in your log file. Don't forget to delete the file.
 
Or even easier, the "id" command or "who am i" will probably work also.
 
Wonboodoo,

Thanks! That worked perfectly. FYI, I used 'id -u -n' and it gives me just the user name.

Thanks again.

LEE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top