<?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 Re: Scripts from cron does'nt execute. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488854#M19224</link>
    <description>First, take a look at /usr/lib/cron/cron.allow&lt;BR /&gt;Make sure the user trying to excecute is allowed entry.  (as the job is scheduled this is probably not the problem)&lt;BR /&gt;&lt;BR /&gt;Next make sure that your script is defined in cron as &lt;BR /&gt;30 10 * * * /full/path/to/binary/script.sh&lt;BR /&gt;&lt;BR /&gt;Make sure the execute bit is set for the user running the script.&lt;BR /&gt;&lt;BR /&gt;Lastly and most importantly is the internals of the script.  Many times PATH is not set, and standard commands are executed without the full path.&lt;BR /&gt;&lt;BR /&gt;If your lazy like me in your scripts define PATH and export for your external calls as well.  If you are security minded, then use full paths to binaries.&lt;BR /&gt;I.E.&lt;BR /&gt;MYVAR=`/usr/bin/ps -ef|/usr/bin/grep top|/usr/bin/grep -v grep |/usr/bin/head -1|/usr/bin/awk '{print $2}'`&lt;BR /&gt;/bin/kill "$MYVAR"&lt;BR /&gt;&lt;BR /&gt;You have to remember that your interactive shells have executable directories set, which will cause scripts to work, where in a raw shell (from at or cron) it will fail.&lt;BR /&gt;&lt;BR /&gt;The easiest way to test this is by unsetting PATH(path in cshell) in ksh or sh and trying to execute your script.&lt;BR /&gt;&lt;BR /&gt;Another thing I always recommend is to have your scripts LOG commands and actions.  It is pretty easy to make a /tmp/myscript.log, remove it if it exists and then touch it.  Pipe script output to /tmp/myscript.log.&lt;BR /&gt;&lt;BR /&gt;This will tell you exactly what is going on.  I.E  grep not found, awk not found,etc...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon</description>
    <pubDate>Thu, 01 Feb 2001 11:56:55 GMT</pubDate>
    <dc:creator>Shannon Petry</dc:creator>
    <dc:date>2001-02-01T11:56:55Z</dc:date>
    <item>
      <title>Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488851#M19221</link>
      <description>Hi&lt;BR /&gt;On a 64 bit hp-ux 11.00 the following occurs:&lt;BR /&gt;&lt;BR /&gt;Running a script manually succeeds:&lt;BR /&gt;ksh&amp;gt;/path/script.sh&lt;BR /&gt;&lt;BR /&gt;Entering the same script into crontab:&lt;BR /&gt;30 10 * * * /path/script.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;does'nt work.&lt;BR /&gt;&lt;BR /&gt;In /var/adm/cron/log the entries:&lt;BR /&gt;&amp;gt;CMD:/path/script.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&amp;gt;bico 2226 c Thu Feb 1 10:30:00 MET 2001&lt;BR /&gt;&lt;BICO 2226="" c="" thu="" feb="" 1="" 00="" met="" 2001="" rc="1&amp;lt;BR"&gt;&lt;/BICO&gt;&lt;BR /&gt;Other scripts succeeds with the following log entries:&lt;BR /&gt;&amp;gt;CMD:/path/test_script.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&amp;gt;bico 2302 c Thu Feb 1 10:45:00 MET 2001&lt;BR /&gt;&amp;gt;bico 2302 c Thu Feb 1 10:45:01 MET 2001&lt;BR /&gt;&lt;BR /&gt;What is wrong?&lt;BR /&gt;&lt;BR /&gt;Whats the rc=1 entry in the log?&lt;BR /&gt;&lt;BR /&gt;Andreas</description>
      <pubDate>Thu, 01 Feb 2001 11:43:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488851#M19221</guid>
      <dc:creator>Andreas D. Skjervold</dc:creator>
      <dc:date>2001-02-01T11:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488852#M19222</link>
      <description>Hi&lt;BR /&gt;A script from cron does not have the same environmental variables as running it from a login.&lt;BR /&gt;&lt;BR /&gt;You must set in your script these variables - sh etc.&lt;BR /&gt;&lt;BR /&gt;HTH &lt;BR /&gt;Paula</description>
      <pubDate>Thu, 01 Feb 2001 11:50:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488852#M19222</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2001-02-01T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488853#M19223</link>
      <description>Hi !&lt;BR /&gt;&lt;BR /&gt;I think rc=1 mean the process return code was 1. &lt;BR /&gt;&lt;BR /&gt;regards, Saa</description>
      <pubDate>Thu, 01 Feb 2001 11:56:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488853#M19223</guid>
      <dc:creator>Sandor Horvath_2</dc:creator>
      <dc:date>2001-02-01T11:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488854#M19224</link>
      <description>First, take a look at /usr/lib/cron/cron.allow&lt;BR /&gt;Make sure the user trying to excecute is allowed entry.  (as the job is scheduled this is probably not the problem)&lt;BR /&gt;&lt;BR /&gt;Next make sure that your script is defined in cron as &lt;BR /&gt;30 10 * * * /full/path/to/binary/script.sh&lt;BR /&gt;&lt;BR /&gt;Make sure the execute bit is set for the user running the script.&lt;BR /&gt;&lt;BR /&gt;Lastly and most importantly is the internals of the script.  Many times PATH is not set, and standard commands are executed without the full path.&lt;BR /&gt;&lt;BR /&gt;If your lazy like me in your scripts define PATH and export for your external calls as well.  If you are security minded, then use full paths to binaries.&lt;BR /&gt;I.E.&lt;BR /&gt;MYVAR=`/usr/bin/ps -ef|/usr/bin/grep top|/usr/bin/grep -v grep |/usr/bin/head -1|/usr/bin/awk '{print $2}'`&lt;BR /&gt;/bin/kill "$MYVAR"&lt;BR /&gt;&lt;BR /&gt;You have to remember that your interactive shells have executable directories set, which will cause scripts to work, where in a raw shell (from at or cron) it will fail.&lt;BR /&gt;&lt;BR /&gt;The easiest way to test this is by unsetting PATH(path in cshell) in ksh or sh and trying to execute your script.&lt;BR /&gt;&lt;BR /&gt;Another thing I always recommend is to have your scripts LOG commands and actions.  It is pretty easy to make a /tmp/myscript.log, remove it if it exists and then touch it.  Pipe script output to /tmp/myscript.log.&lt;BR /&gt;&lt;BR /&gt;This will tell you exactly what is going on.  I.E  grep not found, awk not found,etc...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon</description>
      <pubDate>Thu, 01 Feb 2001 11:56:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488854#M19224</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2001-02-01T11:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488855#M19225</link>
      <description>Hate to say this , but is the script definately&lt;BR /&gt;executable (e.g. -rwx-r-x-r-x)&lt;BR /&gt;&lt;BR /&gt;runing ksh scriptname will execute it even if&lt;BR /&gt;the permissions are wrong</description>
      <pubDate>Thu, 01 Feb 2001 11:57:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488855#M19225</guid>
      <dc:creator>Andrew Lartey</dc:creator>
      <dc:date>2001-02-01T11:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488856#M19226</link>
      <description>Thanks everyone!&lt;BR /&gt;&lt;BR /&gt;It turned out that an undefined enviroment variable was the cause..&lt;BR /&gt;&lt;BR /&gt;Andreas</description>
      <pubDate>Thu, 01 Feb 2001 14:40:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488856#M19226</guid>
      <dc:creator>Andreas D. Skjervold</dc:creator>
      <dc:date>2001-02-01T14:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Scripts from cron does'nt execute.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488857#M19227</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;rc=1 entry means return code of the program.&lt;BR /&gt;&lt;BR /&gt;-Jaimin Parikh</description>
      <pubDate>Thu, 08 Mar 2001 00:02:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripts-from-cron-does-nt-execute/m-p/2488857#M19227</guid>
      <dc:creator>Jaimin Parikh</dc:creator>
      <dc:date>2001-03-08T00:02:30Z</dc:date>
    </item>
  </channel>
</rss>

