- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: crontab for specific user
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
тАО08-22-2007 01:05 AM
тАО08-22-2007 01:05 AM
I need to prepare a crontab on the oracle user. How to write the crontab line and to be sure that user profile will be read before calling the script ?
With AIX i can write something like that:
50 12 * * * /usr/bin/ksh -c "( . /etc/profile; . /gespxpm/ms/users/gespxpm/.profile >/dev/null; . /gespxpm/ms/exp/jcl/ADM_ORA_MajTableSuiviActivite.ksh dba_tools dba >/dev/null 2>&1)"
How to with Hp-UX ?
Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2007 01:11 AM
тАО08-22-2007 01:11 AM
Re: crontab for specific user
I suggest building the profile read into the script.
That seems much easier than what you are doing in AIX.
/usr/bin/su -c username
That format will work in cron.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2007 01:41 AM
тАО08-22-2007 01:41 AM
SolutionThis would work with HP-UX but you would want to source the user's ".profile" since that is a user's local view whereas '/etc/profile' is the global view.
Having said that, however, there are better ways than sourcing a profile. A profile is designed for interactive use during login. As such, HP-UX '.profile's contain terminal-interactive 'stty' and 'tset' commands that expect the process to be attached to a terminal. A crontask has no controlling terminal and thus sourcing a '.profile' will yield "not a typewriter" messages when 'stty' and/or 'tset' commands execute.
Certainly, you can redirect STDERR to '/dev/null' to eliminate these messages, but that may hide *useful* messages too. One better approach is to only conditionaly execute the 'stty' and 'tset' commands if your environment is associated with a terminal:
if [ -t 0 ]; then
...
A second approach is to put your environmental variables in a file that is separate from your profile. Then, source that file in your profile for logins as well as in crontasks and scripts as needed.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2007 02:27 AM
тАО08-22-2007 02:27 AM
Re: crontab for specific user
the oracle user crontab below doesn't works.
00,10,20,30,40,50 * * * * /usr/bin/su - oracle /logiciel/app/oracle/oas10g/measures/GenerateOASMeasures.ksh
I finally prefer:
00,10,20,30,40,50 * * * * /usr/bin/ksh -c "( . /etc/profile; . /logiciel/app/oracle/.profile > /dev/null; . /logiciel/app/oracle/oas10g/m
easures/GenerateOASMeasures.ksh >/dev/null 2>&1)"
Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2007 02:40 AM
тАО08-22-2007 02:40 AM
Re: crontab for specific user
# su - oracle -c "script"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2007 09:18 PM
тАО08-22-2007 09:18 PM
Re: crontab for specific user
# crontab -e
If cron won't work, try to find error in /var/adm/cron/log. If log has no info, suggest:
(1) check user's incoming mail (system will sent messages if cron failed.
(2) add additioanl entry at cron command to get more hint/error at /tmp/err.txt if cron not working; for example
* * * * * /myscript >> /tmp/err.txt 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2007 04:10 AM
тАО08-23-2007 04:10 AM
Re: crontab for specific user
Regards
Den