1833903 Members
1922 Online
110063 Solutions
New Discussion

Re: Cron

 
Gabriel Valdez_1
Occasional Advisor

Cron

I would like to run a unidata process as a cron using a login other than root. Can this be done from SAM. If not how do I submitt a cronjob as a user other than root. I have a script that will login to unidata and run my process but when tring to add as a cron in SAM I get error because I a root and unidata does not recognize root.
8 REPLIES 8
Sanjay_6
Honored Contributor

Re: Cron

Hi,

If you want to run this job as root try to do a su as the user who is allowed to run thisjob,

cron_schedule su - allowed_user -c "unidata_job_with_path"

Hope this helps.

Regds
Robert-Jan Goossens
Honored Contributor

Re: Cron

Hi Gabriel,

edit the /var/adm/cron/cron.allow

su - user

crontab -e

Hope this helps,
Robert-Jan
A. Clay Stephenson
Acclaimed Contributor

Re: Cron

You need to add the user "unidata" to /var/adm/cron/cron.allow. Afterwards, you can then su - unidata and use the crontab command to read in your cronjobs for that user.

If you want to edit a crontab entry later for this user then su - unidata,
crontab -l > unidata_cron # unloads current entries
vi unidata_cron and make your changes
crontab < unidata_cron # reload the crontab
will
If it ain't broke, I can fix that.
Jan Sladky
Trusted Contributor

Re: Cron

Hi Gab,

the easiest way is edit crontab for another user

su - user

crontab -e

2 * * * * $PATH/script.sh


contab -l displays submitted jobs

dont forget for env setting in your script, because cron doesn't use profile

rgds Jan




GSM, Intelligent Networks, UNIX
Sanjay_6
Honored Contributor

Re: Cron

Hi Gabriel,

do "man crontab" to find what is neccessary for a user to run his own cron job. You can allow the user to run his own cron job and setup the cron job for that user.

Hope this helps.

Regds
Gabriel Valdez_1
Occasional Advisor

Re: Cron

# su datatel
$ crontab -e
Could not connect to ToolTalk service: TT_ERR_PROCID The process id passed is not valid.

this is the error I get when tring to setup this script as a cron
Sanjay_6
Honored Contributor

Re: Cron

Hi,

Maybe this link would help you identify the cause and find a solution.

http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000063199258

The itrc doc id is CDEKBRC00003554.

Hope this helps.

Regds
Rick Garland
Honored Contributor

Re: Cron

This needs to be run as a root user but you want cron as other than root user?

SUDO can be very useful for this situation. Call cron as the unidata user, in the sudoers file you have the unidata user allowed to run this script as root, and the cron script makes a sudo unidata script" call.