- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- running scripts 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
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
08-12-2002 11:31 PM
08-12-2002 11:31 PM
running scripts from cron
I've read the cron and crontab manpages and see no reason why it should not work.
Are there some subtleties here that I'm missing? How does a script run from cron differ from a script run interactively? Are there any limitations?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:35 PM
08-12-2002 11:35 PM
Re: running scripts from cron
The PATH variable is completely different when run from cron. In your script to be run from cron set PATH to everything you need and it will run fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:41 PM
08-12-2002 11:41 PM
Re: running scripts from cron
What kind of error do you get from that script? One other difference is that scripts from cron have no controlling tty.
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:41 PM
08-12-2002 11:41 PM
Re: running scripts from cron
Try getting cron to run an env command and compare its output to that from env run after you've logged in and you'll see the differences.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:43 PM
08-12-2002 11:43 PM
Re: running scripts from cron
What your typically missing are the environment parameters (oracle stuff for example). You have to set EVERYTHING you need in your script.
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:43 PM
08-12-2002 11:43 PM
Re: running scripts from cron
Set the PATH in your script.
Source your profile in the script.
Set the path in the crontab entry.
Source the profile in the crontab entry.
The two latter cond be something like:
0 0 * * * PATH=$PATH:/mypath;/home/trond/cronscript
0 0 * * * /home/trond/.profile;/home/trond/cronscript
Regards,
Trond
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2002 11:52 PM
08-12-2002 11:52 PM
Re: running scripts from cron
The first is with the command line to Oracle's rman. The program always throws an exception like the command line is malformed. I tried asking Oracle when exactly this command line parsing error can occur, but they would not say.
The second error is that the initial script has a while loop processing a list of database instances. When the above error occurs within a second shell script, I end the script with a "return" and the first script ends the while loop instead of continuing to the next instance.
I've checked the script and environment very carefully using set -x and echos and all seems to be as expected.
If cron has no tty, what effect does this have?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 12:33 AM
08-13-2002 12:33 AM
Re: running scripts from cron
A neat trick if the cronjob problem is env or rlimit related is to use at(1) instaed. The job is also run by cron, but the runtime environment is prepared before.
So as a test:
# echo 'schriptname' | at now
If you have no controlling tty then several command (like stty(1) fail). Also most tty-related ioctl's are failing with ENOTTY (see termio(7)).
Impact of this depends... sometimes problems are cured by aggressively redirecting stdin/stdout/stderr to some files.
Regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 01:13 AM
08-13-2002 01:13 AM
Re: running scripts from cron
. ~username/.profile
This will load the .profile and really really help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 12:10 AM
08-14-2002 12:10 AM
Re: running scripts from cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 12:34 AM
08-14-2002 12:34 AM
Re: running scripts from cron
A non interactive shell will exit if it detect any error ( see man ksh :
-e If the shell is non-interactive and if a
command fails, execute the ERR trap, if
set, and exit immediately. This mode is
disabled while reading profiles. )
I use to include
set -x
exec 2>/tmp/cronjob.err
while debugging on the begining of the script files, just after #!/usr/bin/ksh.
Now run you job and compare this file agians you interactive ksh -x.
also you can Check /usr/lib/cron/log file for status of the jobs:
> root 24794 c Wed Aug 14 02:00:00 MEST 2002
< root 24794 c Wed Aug 14 05:08:15 MEST 2002 rc=1
rc=1 = return code 1.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 03:58 PM
08-14-2002 03:58 PM
Re: running scripts from cron
It's a good idea to source the crontab user's .profile or .login or .cshrc file within the script that cron is spawning. This way the user's environment will be properly set when the script runs. It is also a good idea to redirect standard out and error out to /dev/null on the line in crontab that launches your script, so no noise messages will clutter up the system console.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 01:05 AM
08-23-2002 01:05 AM
Re: running scripts from cron
The rman error is:
Backup failed for c7t6
--------------------------------------------------------------
performing exec1 bak.sh c7t6
ksh -c . /home/oracle/rman/bak.sh c7t6
.........................
Backing up instance c7t6
.........................
rman target=/ catalog=rman/rman@c7r1 cmdfile=/home/oracle/tmp/bak.rman log=/u06/backup/log/bak_c7t6_20020823.log
Argument Value Description
-----------------------------------------------------------------------------
target quoted-string connect-string for target database
rcvcat quoted-string connect-string for recovery catalog
debug none if specified, activate debugging mode
cmdfile quoted-string name of input command file
msglog quoted-string name of output message log file
trace quoted-string name of output debugging message log file
append none if specified, msglog opened in append mode
nocatalog none if specified, then no recovery catalog
-----------------------------------------------------------------------------
Both single and double quotes (' or ") are accepted for a quoted-string.
Quotes are not required unless the string contains embedded white-space.
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00552: syntax error in command line arguments
RMAN-01005: syntax error: found "auxiliary": expecting one of: "all, backup, change, connect, full, force, identifier, k, nocatalog, obsolete, plsql"
RMAN-01007: at line 2 column 1 file: command line arguments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 01:30 AM
08-23-2002 01:30 AM
Re: running scripts from cron
crontab calls
Backall :-
#!/usr/bin/sh
#################################################
#
# bakall: stub for calling bakall.sh from cron
#
#################################################
/usr/bin/ksh -c ". $HOME/rman/bakall.sh"
$HOME is not defined.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 01:44 AM
08-23-2002 01:44 AM
Re: running scripts from cron
cron defines $HOME.
(but thanks for looking at this mess :) )
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 02:06 AM
08-23-2002 02:06 AM
Re: running scripts from cron
I had a look at your scripts.
As I understand bak.sh works if it is started interactive but not if started by cron.
bak.sh creates a rman sript and starts rman with this script.
What happens if you run the rman script which is created from bak.sh run by cron and run this "cron created" rman script interactive from rman.
Is it any difference in this rman scripts if it created from a interactive bak.sh or from a bak.sh started by cron ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 02:17 AM
08-23-2002 02:17 AM
Re: running scripts from cron
Thanks for looking at this.
I checked the created rman scripts as well (I opened an iTAR with Oracle and they made me jump through hoops checking things like this and then refused to help me with the problem because they saw it as a shell programming problem).
I kept a copy of all of the scripts as they appeared and then ran them one by one and they worked.
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2002 02:20 AM
08-23-2002 02:20 AM
Re: running scripts from cron
But it's true that I've never tried just running the rman direct from cron.
I think a good immitation would be to run a.sh from crontab where a.sh is a bourne shell and it runs b.sh which is ksh which then runs the rman script direct...
I'll play with that.
Ryan