|
Home > Archive > Unix administration > December 2006 > cron help on solaris 10
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
cron help on solaris 10
|
|
| amadain 2006-12-15, 1:20 pm |
| Hi
I wonder if anyone can help me. I can't seem to get cron to accept an
environmental variable. Firstly I created a file for cron and loaded it
into cron:
cat /tmp/mycrontab2
0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
/db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
/db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
/db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
/db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
bash-3.00$
bash-3.00$ crontab /tmp/mycrontab2
This verifies that crontab has the new instructions:
bash-3.00$ crontab -l
0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
/db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
/db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
/db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
/db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
bash-3.00$
Next I decided that I'd like cron to run from a bash shell so I
identified where bash runs from and added the SHELL command to my cron
script
bash-3.00$ which bash
/usr/bin/bash
bash-3.00$ cat /tmp/mycrontab2
SHELL=/usr/bin/bash
0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
/db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
/db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
/db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
/db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
bash-3.00$
Now when I try to upload the ammended instruction set to cron I get the
following:
bash-3.00$ crontab /tmp/mycrontab2
SHELL=/usr/bin/bash
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.
bash-3.00$
>From all of the man pages and research I have done on the web there
should be nothing wrong with setting cron to run for a shell in this
manner so what have I missed?
Confused
| |
| Sridhar Adusumilli 2006-12-15, 1:20 pm |
| Don't use cron file to load environment variables. It is not intended
for that purpose. If you want to load the environment variables try to
put them in a .profile or .cshrc file.
Sri
amadain wrote:
> Hi
> I wonder if anyone can help me. I can't seem to get cron to accept an
> environmental variable. Firstly I created a file for cron and loaded it
> into cron:
>
> cat /tmp/mycrontab2
> 0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
> /db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
> 2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
> /db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
> 4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
> /db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
> 6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
> /db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
> bash-3.00$
> bash-3.00$ crontab /tmp/mycrontab2
>
> This verifies that crontab has the new instructions:
> bash-3.00$ crontab -l
> 0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
> /db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
> 2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
> /db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
> 4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
> /db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
> 6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
> /db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
> bash-3.00$
>
> Next I decided that I'd like cron to run from a bash shell so I
> identified where bash runs from and added the SHELL command to my cron
> script
>
> bash-3.00$ which bash
> /usr/bin/bash
> bash-3.00$ cat /tmp/mycrontab2
> SHELL=/usr/bin/bash
> 0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
> /db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
> 2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
> /db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
> 4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
> /db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
> 6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
> /db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
> bash-3.00$
>
> Now when I try to upload the ammended instruction set to cron I get the
> following:
> bash-3.00$ crontab /tmp/mycrontab2
> SHELL=/usr/bin/bash
> crontab: error on previous line; unexpected character found in line.
> crontab: errors detected in input, no crontab file generated.
> bash-3.00$
>
>
> should be nothing wrong with setting cron to run for a shell in this
> manner so what have I missed?
>
> Confused
| |
| amadain 2006-12-15, 1:20 pm |
| Yes I will do that but I was just wondering if this feature is disabled
from cron. For the man pages for cron
(http://www.rt.com/man/crontab.5.html) the shell can be set thus:
"Several environment variables are set up automatically by the cron(8)
daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set
from the /etc/passwd line of th crontab's owner. HOME and
SHELL may be overridden by set-tings in the crontab; LOGNAME may not."
M
Sridhar Adusumilli wrote:[vbcol=seagreen]
> Don't use cron file to load environment variables. It is not intended
> for that purpose. If you want to load the environment variables try to
> put them in a .profile or .cshrc file.
>
>
> Sri
>
>
>
> amadain wrote:
| |
| Sridhar Adusumilli 2006-12-15, 1:20 pm |
| What shell are you using. Can you make sure SHELL=/usr/bin/bash is
valid in your shell
Sri
amadain wrote:[vbcol=seagreen]
> Yes I will do that but I was just wondering if this feature is disabled
> from cron. For the man pages for cron
> (http://www.rt.com/man/crontab.5.html) the shell can be set thus:
> "Several environment variables are set up automatically by the cron(8)
> daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set
> from the /etc/passwd line of th crontab's owner. HOME and
> SHELL may be overridden by set-tings in the crontab; LOGNAME may not."
>
> M
>
>
>
> Sridhar Adusumilli wrote:
| |
| amadain 2006-12-15, 1:20 pm |
| I did:[vbcol=seagreen]
it was one of the things I checked before setting it up. Its probably
not supported by solaris cron. I also have linux servers and what works
in one os doesn't necessarily work in another (even if they are both
Unix)
Thanks
Sridhar Adusumilli wrote:[vbcol=seagreen]
> What shell are you using. Can you make sure SHELL=/usr/bin/bash is
> valid in your shell
>
>
> Sri
>
>
> amadain wrote:
| |
| Doug Freyburger 2006-12-15, 7:25 pm |
| amadain wrote:
>
> ... but I was just wondering if this feature is disabled
> from cron. For the man pages for cron
> (http://www.rt.com/man/crontab.5.html) the shell can be set thus:
> "Several environment variables are set up automatically by the cron(8)
> daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set
> from the /etc/passwd line of th crontab's owner. HOME and
> SHELL may be overridden by set-tings in the crontab; LOGNAME may not."
Please switch from top posting. Thanks in advance.
The web page you mention isn't from one of the main UNIX vendors.
Which version are you running? The way that's worded the env
variables are set at execution time so it sounds like a line-by-line
setting.
[vbcol=seagreen]
Solaris, HPUX, AIX, Tru64 don't have this though I may remember
wrong for Tru64.
If your scripts are in bash, is it that hard to translate them to
bourne?
Lots of scripts that I write end up switchable with very small changes.
| |
| Tintin 2006-12-16, 1:31 am |
|
"amadain" <mfmdevine@gmail.com> wrote in message
news:1166197998.688584.69130@73g2000cwn.googlegroups.com...
> Hi
> I wonder if anyone can help me. I can't seem to get cron to accept an
> environmental variable. Firstly I created a file for cron and loaded it
> into cron:
>
> cat /tmp/mycrontab2
> 0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
> /db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
> 2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
> /db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
> 4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
> /db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
> 6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
> /db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
> bash-3.00$
> bash-3.00$ crontab /tmp/mycrontab2
>
> This verifies that crontab has the new instructions:
> bash-3.00$ crontab -l
> 0 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 221 >>
> /db/rpsdir/rpsuser/rpsbin/probe221_`date '+\%T'`.txt 2>&1
> 2 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 222 >>
> /db/rpsdir/rpsuser/rpsbin/probe222_`date '+\%T'`.txt 2>&1
> 4 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 223 >>
> /db/rpsdir/rpsuser/rpsbin/probe223_`date '+\%T'`.txt 2>&1
> 6 23 * * 0,5,6 /db/rpsdir/rpsuser/rpsbin/brian_probe 220 >>
> /db/rpsdir/rpsuser/rpsbin/probe220_`date '+\%T'`.txt 2>&1
> bash-3.00$
>
> Next I decided that I'd like cron to run from a bash shell so I
> identified where bash runs from and added the SHELL command to my cron
> script
And you saw that syntax in the crontab man page? (that's a retorical
question).
--
Posted via a free Usenet account from http://www.teranews.com
| |
| Carl Lowenstein 2006-12-17, 7:32 pm |
| In article <45834523$0$15496$88260bb3@free.teranews.com>,
Tintin <tintin@invalid.invalid> wrote:
>
>"amadain" <mfmdevine@gmail.com> wrote in message
>news:1166197998.688584.69130@73g2000cwn.googlegroups.com...
long crontab snipped[vbcol=seagreen]
>
>And you saw that syntax in the crontab man page? (that's a retorical
>question).
>
>
For those who have not yet tumbled to the difference between versions of
cron, the features above come with Paul Vixie's cron, which has been
around for at least a decade, and seems to be standard in most Linux
systems. Solaris cron doesn't do it that way.
carl
--
carl lowenstein marine physical lab u.c. san diego
clowenst@ucsd.edu
|
|
|
|
|