Operating System - HP-UX
1753765 Members
5798 Online
108799 Solutions
New Discussion

Re: one script to be executed in cron

 
SOLVED
Go to solution
zxcv
Super Advisor

one script to be executed in cron

hi guys ,

 

i want to execute a common script  which  should be executed by 2 diff users in cron ...

 

user1  to execute script at  day time 06-22

user2 to excute same script at  22-06

 

the problm we call .profile in that script....so hw should i call the same..for 2 users.....??? 

4 REPLIES 4
Larry Klasmier
Honored Contributor

Re: one script to be executed in cron

Are you running the script for each user's crontab?   I am assuming the issue is that each users profile is different.   Why not just make this a variable and provide each user's profile as part of the command to execute the script.

James R. Ferguson
Acclaimed Contributor

Re: one script to be executed in cron

Hi:

 

I do not practice putting environmental variables in my login profiles.  Rather, I source (read, using the 'dot-space-filename' notation) any variable settings I need from an independent file.

 

You don't offer whether these two users will be executed by the 'root' crontab or as crontab's belonging to each user.  If 'root' is the one executing, you could simply do :

 

su - theuser -c script_to_run

 

The 'su -' causes the login profile of the user to be executed before the 'script_to_run'.

 

If each user is going to execute the common script, the encapsulation of the necessary environmental variables into a standalone file which *both* the login profile and the script can source (read) is preferred in my opinion.

 

Regards!

 

...JRF...

Dennis Handly
Acclaimed Contributor
Solution

Re: one script to be executed in cron

>the problem we call .profile in that script.

 

If you want two different .profile files, you can use: ~/.profile

zxcv
Super Advisor

Re: one script to be executed in cron

hi Dennis ,

 

u were spot on ..thankss...very much...