Operating System - Linux
1753380 Members
5887 Online
108792 Solutions
New Discussion юеВ

scheduling a shell script

 
SOLVED
Go to solution
Shivkumar
Super Advisor

scheduling a shell script

Dear Sirs,

i want to schedule a shell script jasmine.sh to execute every day at a particular time but don't want to put it in cron job. i want to execute as a login account on mine i.e. as a non-root user.

how can i achieve this ?

thanks,
shiv
22 REPLIES 22
Sivakumar TS
Honored Contributor
Solution

Re: scheduling a shell script



Dear Shiv,

you can add the entry in the crontab, ( in the command field)

su - -c

now, in the sheduled intervals , the script will be executed as the specified in the above command ( and not as root). You can specify your username and your script.

With Regards,

Siva.
Nothing is Impossible !
Pete Randall
Outstanding Contributor

Re: scheduling a shell script

You can use at:

echo "/full_path/script.sh" | at 0200 tomorrow

Just add that line to the end of your script and it will repeat every day.


Pete

Pete
Patrick Wallek
Honored Contributor

Re: scheduling a shell script

You can use cron to schedule jobs for users other than root.

First the user must be allowed to use cron. Add the user to /var/adm/cron/cron.allow

Then the user can edit his/her crontab with the 'crontab -e' command. Or root can edit another users crontab via 'crontab -e username'.

When the jobs run they will be run as that user.
Lolupee
Regular Advisor

Re: scheduling a shell script

Pete has just given the best idea.

The use of echo "/$PATH/filename" | at
Lolupee
Regular Advisor

Re: scheduling a shell script

apologies, you must be permitted to use "at" on the server for this.

let sysadm add your name to at.allow
John Payne_2
Honored Contributor

Re: scheduling a shell script

HP SIM can do this for you. (I am talking SIM 5, not the older revs. I also don't know if you have it installed or are familiar with it.)

I use HP SIM to login and run commands for me regularly, and it has a 'run now' option, and a 'schedule' option.

Short of running cron or some other scheduler, this is likely your best (free) bet. SIM is normally used for monitoring, but I use it for sysadmin tasks much more than monitoring.

Hope it helps

John
Spoon!!!!
Arunvijai_4
Honored Contributor

Re: scheduling a shell script

Hi Shiv,

"at" is the command to help you.

http://docs.hp.com/en/B2355-60127/at.1.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: scheduling a shell script

hi,

i usually prefer:

20 09 * * * echo "/prod/myscripts/jasmine.sh"|su - shiv 1>/prod/script/logfiles/output-jasmine.crn 2>/prod/script/logfiles/error-jasmine.crn

using cron of course

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Senthil Prabu.S_1
Trusted Contributor

Re: scheduling a shell script

Hi shiva,
you can use both "at" and cron jobs to do it.
One man's "magic" is another man's engineering. "Supernatural" is a null word.