<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic running scripts from cron in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784832#M943598</link>
    <description>I have a script that runs perfectly when I run it interactively from ksh, but never works from cron. I've been very careful to set up an identical environment and have set the first line of each file to #!/usr/bin/ksh.&lt;BR /&gt;&lt;BR /&gt;I've read the cron and crontab manpages and see no reason why it should not work.&lt;BR /&gt;&lt;BR /&gt;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?</description>
    <pubDate>Tue, 13 Aug 2002 06:31:36 GMT</pubDate>
    <dc:creator>Ryan Kogelheide</dc:creator>
    <dc:date>2002-08-13T06:31:36Z</dc:date>
    <item>
      <title>running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784832#M943598</link>
      <description>I have a script that runs perfectly when I run it interactively from ksh, but never works from cron. I've been very careful to set up an identical environment and have set the first line of each file to #!/usr/bin/ksh.&lt;BR /&gt;&lt;BR /&gt;I've read the cron and crontab manpages and see no reason why it should not work.&lt;BR /&gt;&lt;BR /&gt;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?</description>
      <pubDate>Tue, 13 Aug 2002 06:31:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784832#M943598</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-13T06:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784833#M943599</link>
      <description>&lt;BR /&gt;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.&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 06:35:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784833#M943599</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-08-13T06:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784834#M943600</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;What kind of error do you get from that script? One other difference is that scripts from cron have no controlling tty.&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 13 Aug 2002 06:41:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784834#M943600</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-08-13T06:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784835#M943601</link>
      <description>Cron doesn't run any of the normal scripts to condition your environment e.g. /etc/profile and .profile.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Tue, 13 Aug 2002 06:41:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784835#M943601</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-08-13T06:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784836#M943602</link>
      <description>Hi,&lt;BR /&gt;What your typically missing are the environment parameters (oracle stuff for example). You have to set EVERYTHING you need in your script.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
      <pubDate>Tue, 13 Aug 2002 06:43:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784836#M943602</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-08-13T06:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784837#M943603</link>
      <description>I agrea with Stefan. What you can do is:&lt;BR /&gt;Set the PATH in your script.&lt;BR /&gt;Source your profile in the script.&lt;BR /&gt;Set the path in the crontab entry.&lt;BR /&gt;Source the profile in the crontab entry.&lt;BR /&gt;&lt;BR /&gt;The two latter cond be something like:&lt;BR /&gt;0 0 * * *  PATH=$PATH:/mypath;/home/trond/cronscript&lt;BR /&gt;&lt;BR /&gt;0 0 * * *  /home/trond/.profile;/home/trond/cronscript&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Trond</description>
      <pubDate>Tue, 13 Aug 2002 06:43:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784837#M943603</guid>
      <dc:creator>Trond Haugen</dc:creator>
      <dc:date>2002-08-13T06:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784838#M943604</link>
      <description>There are two problems:&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;I've checked the script and environment very carefully using set -x and echos and all seems to be as expected.&lt;BR /&gt;&lt;BR /&gt;If cron has no tty, what effect does this have?</description>
      <pubDate>Tue, 13 Aug 2002 06:52:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784838#M943604</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-13T06:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784839#M943605</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;So as a test:&lt;BR /&gt;&lt;BR /&gt;# echo 'schriptname' | at now&lt;BR /&gt;&lt;BR /&gt;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)).&lt;BR /&gt;&lt;BR /&gt;Impact of this depends... sometimes problems are cured by aggressively redirecting stdin/stdout/stderr to some files.&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 13 Aug 2002 07:33:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784839#M943605</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-08-13T07:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784840#M943606</link>
      <description>Within the script slot in:-&lt;BR /&gt;&lt;BR /&gt;. ~username/.profile&lt;BR /&gt;&lt;BR /&gt;This will load the .profile and really really help</description>
      <pubDate>Tue, 13 Aug 2002 08:13:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784840#M943606</guid>
      <dc:creator>bjs144</dc:creator>
      <dc:date>2002-08-13T08:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784841#M943607</link>
      <description>There is another quirk in cron, described in small print in the man page. If the command line in cron includes %, it is treated as a new line.  This may give the 'malformed command' error.</description>
      <pubDate>Wed, 14 Aug 2002 07:10:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784841#M943607</guid>
      <dc:creator>Martin Robinson</dc:creator>
      <dc:date>2002-08-14T07:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784842#M943608</link>
      <description>THe PATH, env and tty tipical issues are described yet in this thread.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;A non interactive shell will exit if it detect any error ( see man ksh :&lt;BR /&gt;&lt;BR /&gt;                        -e      If the shell is non-interactive and if a                                                          &lt;BR /&gt;                                  command fails, execute the ERR trap, if                                                           &lt;BR /&gt;                                  set, and exit immediately.  This mode is                                                          &lt;BR /&gt;                                  disabled while reading profiles.             )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I use to include &lt;BR /&gt;set -x&lt;BR /&gt;exec 2&amp;gt;/tmp/cronjob.err&lt;BR /&gt;&lt;BR /&gt;while debugging on the begining of the script files, just after #!/usr/bin/ksh.&lt;BR /&gt;&lt;BR /&gt;Now run you job and compare this file agians you interactive ksh -x.&lt;BR /&gt;&lt;BR /&gt;also you can Check /usr/lib/cron/log file for status of the jobs:&lt;BR /&gt;&amp;gt;  root 24794 c Wed Aug 14 02:00:00 MEST 2002                                                                                       &lt;BR /&gt;&amp;lt;  root 24794 c Wed Aug 14 05:08:15 MEST 2002 rc=1       &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rc=1 = return code 1.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Aug 2002 07:34:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784842#M943608</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-08-14T07:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784843#M943609</link>
      <description>Hi there,&lt;BR /&gt;   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.</description>
      <pubDate>Wed, 14 Aug 2002 22:58:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784843#M943609</guid>
      <dc:creator>Jack Werner</dc:creator>
      <dc:date>2002-08-14T22:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784844#M943610</link>
      <description>I still have the problem when rman runs, so I'm posting the whole script set for anyone who has the patience to wade through it. I'm no sh expert and perhaps it's not the best coding...&lt;BR /&gt;&lt;BR /&gt;The rman error is:&lt;BR /&gt;&lt;BR /&gt;Backup failed for c7t6&lt;BR /&gt;&lt;BR /&gt;--------------------------------------------------------------&lt;BR /&gt;performing exec1 bak.sh c7t6&lt;BR /&gt;ksh -c . /home/oracle/rman/bak.sh c7t6&lt;BR /&gt;.........................&lt;BR /&gt;Backing up instance c7t6&lt;BR /&gt;.........................&lt;BR /&gt;rman target=/ catalog=rman/rman@c7r1 cmdfile=/home/oracle/tmp/bak.rman log=/u06/backup/log/bak_c7t6_20020823.log&lt;BR /&gt;&lt;BR /&gt;Argument     Value          Description&lt;BR /&gt;-----------------------------------------------------------------------------&lt;BR /&gt;target       quoted-string  connect-string for target database&lt;BR /&gt;rcvcat       quoted-string  connect-string for recovery catalog&lt;BR /&gt;debug        none           if specified, activate debugging mode&lt;BR /&gt;cmdfile      quoted-string  name of input command file&lt;BR /&gt;msglog       quoted-string  name of output message log file&lt;BR /&gt;trace        quoted-string  name of output debugging message log file&lt;BR /&gt;append       none           if specified, msglog opened in append mode&lt;BR /&gt;nocatalog    none           if specified, then no recovery catalog&lt;BR /&gt;-----------------------------------------------------------------------------&lt;BR /&gt;Both single and double quotes (' or ") are accepted for a quoted-string.&lt;BR /&gt;Quotes are not required unless the string contains embedded white-space.&lt;BR /&gt;&lt;BR /&gt;RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============&lt;BR /&gt;RMAN-00552: syntax error in command line arguments&lt;BR /&gt;RMAN-01005: syntax error: found "auxiliary": expecting one of: "all, backup, change, connect, full, force, identifier, k, nocatalog, obsolete, plsql"&lt;BR /&gt;RMAN-01007: at line 2 column 1 file: command line arguments&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Aug 2002 08:05:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784844#M943610</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-23T08:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784845#M943611</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;crontab calls&lt;BR /&gt;Backall :-&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#################################################&lt;BR /&gt;# &lt;BR /&gt;# bakall: stub for calling bakall.sh from cron&lt;BR /&gt;#&lt;BR /&gt;#################################################&lt;BR /&gt;/usr/bin/ksh -c ". $HOME/rman/bakall.sh"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$HOME is not defined.&lt;BR /&gt;&lt;BR /&gt;Paula</description>
      <pubDate>Fri, 23 Aug 2002 08:30:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784845#M943611</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-08-23T08:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784846#M943612</link>
      <description>Paula,&lt;BR /&gt;&lt;BR /&gt;cron defines $HOME.&lt;BR /&gt;&lt;BR /&gt;(but thanks for looking at this mess :) )&lt;BR /&gt;&lt;BR /&gt;Ryan</description>
      <pubDate>Fri, 23 Aug 2002 08:44:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784846#M943612</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-23T08:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784847#M943613</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I had a look at your scripts.&lt;BR /&gt;As I understand bak.sh works if it is started interactive but not if started by cron.&lt;BR /&gt;&lt;BR /&gt;bak.sh creates a rman sript and starts rman with this script.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Is it any difference in this rman scripts if it created from a interactive bak.sh or from a bak.sh started by cron ?&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Aug 2002 09:06:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784847#M943613</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-23T09:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784848#M943614</link>
      <description>Leif,&lt;BR /&gt;&lt;BR /&gt;Thanks for looking at this.&lt;BR /&gt;&lt;BR /&gt;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).&lt;BR /&gt;&lt;BR /&gt;I kept a copy of all of the scripts as they appeared and then ran them one by one and they worked.&lt;BR /&gt;&lt;BR /&gt;Ryan</description>
      <pubDate>Fri, 23 Aug 2002 09:17:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784848#M943614</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-23T09:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: running scripts from cron</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784849#M943615</link>
      <description>Leif,&lt;BR /&gt;&lt;BR /&gt;But it's true that I've never tried just running the rman direct from cron. &lt;BR /&gt;&lt;BR /&gt;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...&lt;BR /&gt;&lt;BR /&gt;I'll play with that.&lt;BR /&gt;&lt;BR /&gt;Ryan</description>
      <pubDate>Fri, 23 Aug 2002 09:20:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/running-scripts-from-cron/m-p/2784849#M943615</guid>
      <dc:creator>Ryan Kogelheide</dc:creator>
      <dc:date>2002-08-23T09:20:17Z</dc:date>
    </item>
  </channel>
</rss>

