![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sudo command not working with cron job. | WhotheWhat | Shell Programming and Scripting | 6 | 12-18-2008 04:10 PM |
| Grep command is not working when put into cron | thiru_cs | Shell Programming and Scripting | 5 | 08-06-2008 05:39 AM |
| formatting textfile inside ksh script using awk not working | tekline | UNIX for Advanced & Expert Users | 6 | 07-03-2007 01:40 AM |
| script not working in CRON | abhijeetkul | Shell Programming and Scripting | 5 | 07-13-2006 05:48 AM |
| looping a array inside inside ssh is not working, pls help | reldb | Shell Programming and Scripting | 5 | 07-07-2006 10:32 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
sudo command is not working inside a script when placed in cron
Hi All,
i have a cron entry like 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /amex/sssmonitor/dss_chk.ksh and the script is like #!/bin/ksh file=`uname -n` > /sunmast/projects/oasis/COREDEV/Dss$file.log > /tmp/output_sss today=`date` varb=`ps -ef | grep java | grep sss | grep -v grep | wc -l` if [ "$varb" -ne 1 ] then echo "FAILED : SSS processes down, Recycling SSS " >> /sunmast/projects/oasis/COREDEV/Dss$file.log sudo /etc/init.d/init.sss start >> /tmp/output_sss else echo "SSS process is running successfully on `uname -n` on $today " >> /sunmast/projects/oasis/COREDEV/Dss$file.log fi MEMSIZE=`ps -e -o vsz,args | grep /amex/dss/sss/java | grep -v grep | cut -d' ' -f1` echo " Memory usage by dss java client in kilobytes is $MEMSIZE on $today " >> /sunmast/projects/oasis/COREDEV/Dss$file.log when i am manully running this script sudo command inside the script is working,But when the cron is executing the sudo command is not working inside the script. Could anyone let me know what could be the possible reason. I have checked that the cron is executing as other command are running except the sudo command. Please help. Thanks ![]() |
|
||||
|
It's probably got something to do with the way you have sudo setup to handle passwords. There are a variety of options:
1. sudo will always ask for a password. 2. sudo will only ask the first time it's run 3. sudo will require no password I'm willing to bet that your script works in your shell because sudo is set to only prompt for a password the first time. When cron calls the script, it is probably hanging waiting on a password to be entered. I'd look at your /etc/sudoers file to see how you're setup. Or, you could just put this job into the root crontab and not worry about sudo at all. |
|
||||
|
I cannot access that file /etc/sudoers as i am not having the access.
Is there any other way other that running the script in root cron?? i tried this also sudo -u <user> -c "/etc/init.d/init.sss start >> /tmp/output_sss " but it is also not working... |
|
||||
|
Well, if you have access to sudo as root, you can modify the sudoers file:
Code:
sudo visudo Code:
sudo crontab -e |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|