- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell and cronjob behave differently
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
Forums
Discussions
Discussions
Discussions
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
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
11-06-2005 07:26 PM
11-06-2005 07:26 PM
I have a small problem with my perl-skript, but not a programming problem.
If I run the script from shell with user root, it works perfectly. If i run it from a cronjob with user root, it doesn't work. I don't know why.
Is there any difference between shell and cron, both using the root-account?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:32 PM
11-06-2005 07:32 PM
Re: Shell and cronjob behave differently
Whne you run the script manually the environment variables are pikced from the profile. But not when the script is scheduled through cron.
Cron does not run profile therefore it's up to you to initialise the variables in the script.
So you have to provide the full paths of the scripts when called from cron.
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:34 PM
11-06-2005 07:34 PM
Re: Shell and cronjob behave differently
If the PATH variable is omitted in the configuration file for cron, no default will be used and file locations will need to be absolute.
Regards,
Sergejs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:45 PM
11-06-2005 07:45 PM
Re: Shell and cronjob behave differently
~regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:45 PM
11-06-2005 07:45 PM
Re: Shell and cronjob behave differently
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:47 PM
11-06-2005 07:47 PM
Re: Shell and cronjob behave differently
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 07:56 PM
11-06-2005 07:56 PM
Re: Shell and cronjob behave differently
/commandline 2>1& mail -s "subject" email@your.net
There is also a cron log in /var
If there is nothing then cron isn't running.
ps -ef | grep cron
To start:
/sbin/init.d/cron start
Start configuration file(name at bottom)
#!/sbin/sh
# @(#) $Revision: 72.3 $
# Cron configuration. See cron(1m)
#
# CRON: Set to 1 to start cron daemon
#
CRON=1
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/rc.config.d/cron" [Read only] 7 lines, 129 characters
Please check it out and get back to us.
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
11-06-2005 08:05 PM
11-06-2005 08:05 PM
Re: Shell and cronjob behave differently
Check the url below (docID : W1699733) about 'How can I make a script run euid root?' :
http://www2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000006432514
Hope this information can help you.
Cheers,
AW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 08:06 PM
11-06-2005 08:06 PM
Re: Shell and cronjob behave differently
# crontab -l
post which script line you are executing there.
# Post cron log entries for this execution as,
cat /var/adm/cron/log
When you are execution from shell then it will use specific user logged now. Cron is behaving like another user to execute scripts. Use su - root -c "script". You have to use sudo for not prompting for passwd.
~regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 08:06 PM
11-06-2005 08:06 PM
Re: Shell and cronjob behave differently
I found it.
The problem was, that I didn't use a full path where I was trying to create a new file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2005 08:06 PM
11-06-2005 08:06 PM
Re: Shell and cronjob behave differently
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2005 08:54 PM
11-07-2005 08:54 PM
Solutionmy suggestion is always load the pofile in the script you schedule in cron.
the good way to do this is:
[[ "$(tty)" = "not a tty" ]] && ./.profile
In this way when you run your script interactively the profile won't be loaded while it will be loaded when you will scheule it in crontab or run by nohup, at, etc.
HTH,
Art