- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: su from cron
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 11:31 AM
тАО06-09-2011 11:31 AM
su from cron
I'm trying this from root cron
50 * * * * "su - wmsusr -c /wms/app/zabbix/check_zabbix.sh"
Works fine if I
# su - wmsusr
]: /wms/app/zabbix/check_zabbix.sh
1
2
3
4
5
wmsusr@prodomni ksh[392]:
Here is the script
HOSTNAME=`whoami`
echo 1
value=`ps -fu $HOSTNAME |grep zabbix| grep -v grep| wc -l`
echo 2
if [ $value -eq 0 ]; then
echo 3
rm -f /wms/app/zabbix/agentd.pid
echo 4
/wms/app/zabbix/zabbix_agentd -c /wms/app/zabbix/zabbix_agentd.conf
echo 5
fi
exit 0;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 11:48 AM
тАО06-09-2011 11:48 AM
Re: su from cron
What does the '/var/adm/cron/log' show; particularly the return code (rc=)?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 11:49 AM
тАО06-09-2011 11:49 AM
Re: su from cron
# su - wmsusr -c /wms/app/zabbix/check_zabbix.sh
from root prompt I get this
1
2
logout
#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 01:02 PM
тАО06-09-2011 01:02 PM
Re: su from cron
your second output ran as root, did you stop the agent before running the script? If the agent is running, you will see only 1 and 2 right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 01:33 PM
тАО06-09-2011 01:33 PM
Re: su from cron
I believe Wilfred may have found the reason.
You really ought to change the *name* of the variable that holds the *user* id. Calling the variable "HOSTNAME" is rather misleading :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2011 09:54 PM
тАО06-09-2011 09:54 PM
Re: su from cron
You may want to list what $HOSTNAME and "ps -fu $HOSTNAME" shows so you can make sure what you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2011 04:33 AM
тАО06-14-2011 04:33 AM
Re: su from cron
Hostname is a bad var name but I don't see how it causes the problem... The agent is not running when I'm running the script and from root
su - wmsusr -c /wms/app/zabbix/check_zabbix.sh
Results
~/.kshrc
1
2
logout
Any ideas? THANKS!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2011 04:36 AM
тАО06-14-2011 04:36 AM
Re: su from cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2011 05:10 AM
тАО06-14-2011 05:10 AM
Re: su from cron
> If I su to wmsusr and then run all is fine... Just when I'm calling from roots cron and trying to su to that user do I have an issue.
Why do you 'cron' this as 'root' if you then switch to the 'wmsusr'?
What happens if you 'cron' this task as the 'wmsuer' ?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2011 05:11 AM
тАО06-14-2011 05:11 AM