- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Running a Script 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
Forums
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
10-19-2000 02:31 PM
10-19-2000 02:31 PM
Running a Script from cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2000 02:43 PM
10-19-2000 02:43 PM
Re: Running a Script from cron
the major common difference between command line (shell from login) and cron is the environment (can be seen with: set)
So check your script if it depends on environment variables that where not set by cron. Add these variable definitions to your script.
Another thing is that a process from cron has no input device (not tty assosiation). So getting some dialog input is not available by cron.
Hope this gives you the way.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2000 03:09 PM
10-19-2000 03:09 PM
Re: Running a Script from cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2000 08:04 PM
10-19-2000 08:04 PM
Re: Running a Script from cron
Those command you can run smoothly on a shell becase $PATH has been setup on .profile. But it may not use when running scripts via cron. So, I would suggest all command inside the script should key in path. e.g. /etc/fbackup or /etc/vgdisplay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 03:22 AM
10-20-2000 03:22 AM
Re: Running a Script from cron
I think the first thing to do is look at you mail. Most of the times, your mail will contain error messages that will show why your script did not run as expected. Most probably, the script cannot find your commands or other env. variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 04:13 AM
10-20-2000 04:13 AM
Re: Running a Script from cron
Make sure you are running the correct shell. Cron runs jobs by default with /usr/bin/sh so if you have written and tested a script using your csh or ksh login shell it will not work.
The first line should specify the shell.ie
#!/usr/bin/ksh
Also, as the other answers have said I find that paths and environment settings are a common problem.
Try redirecting stderr to a file to see what the problem is. eg
/script 2>/error.report
Hope it helps,
Paul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 10:42 AM
10-20-2000 10:42 AM
Re: Running a Script from cron
sqlplus username/password @/opt/mimsps/mims_sys/local/script_name
In cron I get this error which tells me it must be the environment variables.
/opt/mimsps/mims_sys/local/usbtest.sh[55]: sqlplus: not found
Any other suggestions??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 11:16 AM
10-20-2000 11:16 AM
Re: Running a Script from cron
You may also want to set your shell in the script with the #!/sbin/ksh line or what ever shell you actually need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 11:27 AM
10-20-2000 11:27 AM
Re: Running a Script from cron
Its clearly the problem with the PATH variable not being set.
Add the following lines to the script begining.
export PATH=$PATH:$ORACLE_HOME/bin.
Also ensure to define ORACLE_HOME variable just before the above line in your script according to your environment.
This should make the script work when placed in cron.
......Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 11:32 AM
10-20-2000 11:32 AM
Re: Running a Script from cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 12:01 PM
10-20-2000 12:01 PM
Re: Running a Script from cron
ORACLE_HOME=/oracle/7.3.3
export PATH=$PATH:$ORACLE_HOME/bin
Now I get this error message.
Message file sp1
Error initializing SQL*Plus
Any last suggestions??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 12:06 PM
10-20-2000 12:06 PM
Re: Running a Script from cron
. /etc/profile
. /home/
at the beginning of your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 12:52 PM
10-20-2000 12:52 PM
Re: Running a Script from cron
ORACLE_HOME=/oracle/7.3.3
export PATH=$PATH:$ORACLE_HOME/bin
Now I get this error message.
Message file sp1
Error initializing SQL*Plus
Any last suggestions??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 01:33 PM
10-20-2000 01:33 PM
Re: Running a Script from cron
As a whole it should look something like the following
PATH=$PATH:$ORACLE_HOME:/bin:$ORACLE_HOME/sqlplus/mesg
Hope fully this works.
......Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2000 12:58 PM
11-09-2000 12:58 PM
Re: Running a Script from cron
crontab entry:
00 5 5 * * /usr/bin/su - username -c "script"
Thanks to all those who gave answers in this matter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 09:27 AM
08-28-2003 09:27 AM
Re: Running a Script from cron
export ORACLE_HOME=
export ORACLE_SID=openview
export PATH=$ORACLE_HOME/bin:$PATH
export ORAENV_ASK=NO
. oraenv
And now it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2003 02:19 PM
08-28-2003 02:19 PM
Re: Running a Script from cron
The easiest way to do this is to include the line
. ~orauser/.profile (or .
HTH
Paulo Fessel