Operating System - HP-UX
1834009 Members
1806 Online
110063 Solutions
New Discussion

Re: Run crontab job problem

 
SOLVED
Go to solution
ust3
Regular Advisor

Re: Run crontab job problem

thx reply,

I think I have mis-understand the previous reply , the sudo works fine in my case.

Dennis Handly
Acclaimed Contributor

Re: Run crontab job problem

>I think I have mis-understand the previous reply, the sudo works fine in my case.

I didn't use sudo. I had a root crontab entry that executed script1. This script did "su - cron_usr". This executed /etc/profile then .profile. The .profile then executed my_script. When my_script returned, the shell finished .profile and got an immediately EOF.

Everything worked except /etc/profile also produced errors because it expects to only be executed from a terminal.
ust3
Regular Advisor

Re: Run crontab job problem

thx replies,

yes , you are right , sudo is not good , if I release sudo to a user , the user have ALL function of root , if I just want a user ONLY have the permission to su another user ( on other root permission ) , what can i do ? thx
Dennis Handly
Acclaimed Contributor

Re: Run crontab job problem

>the user have ALL function of root, if I just want a user ONLY have the permission to su another user (on other root permission)

This was just discussed in this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1145681

I believe this was a security issue, unless you want one specific script and that could check and su to a specific user.

But it seems to me as I keep saying, why not have a crontab entry for cron_usr?
ust3
Regular Advisor

Re: Run crontab job problem

thx Dennis Handly ,

why not add cron entry for cron_usr ?
> as my previous message , if run my script in cron , it is not work , but it is sucessful to run by manual , so I want to add a cron , this cron will su to another user , I check that this method is OK if run by root .
Dennis Handly
Acclaimed Contributor

Re: Run crontab job problem

>if run my script in cron, it is not work

You need to explain or figure out why, is there an obvious error?

As has been mentioned, the obvious reason is that it needs to source .profile before or in the script.

I don't think it needs to have stdin a terminal, because that can't happen with your "su -" on cron.