[vox-tech] Cron Script Error
Ken Bloom
vox-tech@lists.lugod.org
Tue, 26 Aug 2003 20:15:48 -0700
--4Ckj6UjgE2iN1+kY
Content-Type: text/plain; format=flowed; charset=ISO-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On 2003.08.26 15:31, Samuel Merritt wrote:
>=20
> Tim Riley said:
> >
> >
> > Daniel Hurt wrote:
> >
> >> Greetings. I have written a small shell script to modify the login
> >> prompt at certain intervals, just for entertainment purposes. The
> >> when I run the script from the shell prompt it runs fine, but when
> I
> >> execute it as cron job, I receive several errors in via email. I
> am
> >> using Vcron as the cron daemon.
> >>
> >> The crontab entry is as follows:
> >>
> >> */15 * * * * root /etc/init.d/issue
> >
> > This "root" is giving you the "root: command not found" error.
> > The sixth parameter is the command to execute.
> >
> > As far as the "TERM environment variable not set" error:
> > I think the "clear" command is generating this.
> > Just set "export TERM=3Dvt100" at the top of the script.
>=20
>=20
> It looks to me like the /usr/bin/clear isn't needed at all. Right
> below
> that, he's got the lineprintf "\e[2J\e[H" > /etc/issue
> whicl will clobber /etc/issue, including anything that "clear"
> appended to
> it.
I think that he wants to clobber with the clear command (and thereby=20
make the first character of /etc/issue a control character that clears=20
the screen). Using TERM=3Dlinux where I have inserted it will solve the=20
TERM environment variable not set error. (Use of TERM=3Dlinux should be=20
preferred over TERM=3Dvt100, because you know practically for certain=20
that /etc/issue will only be printed to the linux console)
My suggestion regarding this:
YELLOW=3D"\033[1;33m" # Light Red
- /usr/bin/clear >> /etc/issue
- printf "\e[2J\e[H" > /etc/issue
+ TERM=3Dlinux /usr/bin/clear > /etc/issue
+ printf "\e[2J\e[H" >> /etc/issue
echo -e " " >> /etc/issue
As for your other problem, the username field is only used in the=20
global crontab, and is never used in the crontab that you edit using=20
`crontab -e`. As a result, "root" is being interpreted as a command,=20
not a username. Login as root and run crontab -e, or run
sudo crontab -e. Set up the cronjob there.
> >>
> >>
> >> The script /etc/init.d/issue contains the following:
> >> ********************************************************
> >> #!/bin/bash
> >>
> >> R=3D$(cat /etc/gentoo-release | awk '{ print $5,$6 }')
> >> C=3D$(cat /proc/cpuinfo | grep 'model name' | awk '{ print $4,$5,$6
> }')
> >> CS=3D$(cat /proc/cpuinfo | grep 'cpu MHz' | awk '{ print $4 }')
> >> CB=3D$(cat /proc/cpuinfo | grep 'bogomips' | awk '{ print $3 }')
> >> K=3D$(uname -r)
> >> H=3D$(/bin/hostname -f)
> >> M=3D$(( `dmesg | grep "Dentry" | awk '{print $9}'` / 1024 ))
> >> KS=3D`dmesg | grep "Swap" | awk '{print $3}'`
> >> S=3D$(( ${KS%k} / 1024 ))
> >> U=3D$(uptime)
> >> F=3D$(fortune 40% calvin 30% hitchhiker 10% chalkboard 10% starwars
> 10%
> >> bofh- excuses)
> >>
> >> DARK=3D"\033[1;30m" # dark grey
> >> GREY=3D"\033[0m" # default grey / white
> >> WHITE=3D"\033[1;37m" # bright / bold white
> >> PURPLE=3D"\033[0;35m" # purple
> >> BR_GREEN=3D"\033[1;32m" # bright green
> >> BR_BLUE=3D"\033[1;34m" # bright blue
> >> BLACK=3D"\033[0;30m" # black
> >> RED=3D"\033[0;31m" # Red
> >> LT_RED=3D"\033[1;31m" # Light Red
> >> YELLOW=3D"\033[1;33m" # Light Red
> >>
> >> /usr/bin/clear >> /etc/issue
> >> printf "\e[2J\e[H" > /etc/issue
> >> echo -e " " >> /etc/issue
> >> echo -e "$BR_GREEN Gentoo$BR_BLUE Linux$RED Release $R" >>
> /etc/issue
> >> echo -e " " >> /etc/issue
> >> echo -e "$GREY Hostname: $WHITE $H" >> /etc/issue
> >> echo -e " " >> /etc/issue
> >> echo -e "$GREY Kernel: $WHITE $K" >> /etc/issue
> >> echo -e "$GREY Processor:$WHITE $C ( $CS MHz =3D> $CB bogomips)"
> >> >> /etc/issue
> >> echo -e "$GREY Memory: $WHITE $M Mb $GREY Swap: $WHITE $S Mb"
> >> >> /etc/issue
> >> echo -e "$GREY Uptime: $WHITE $U" >> /etc/issue
> >> echo -e " " >> /etc/issue
> >> echo -e "$YELLOW$F$WHITE" >> /etc/issue
> >> echo -e " " >> /etc/issue
> >> cp /etc/issue /etc/issue.net
> >> ********************************************************
> >>
> >> The two errors that I am recieving are as follows:
> >> ********************************************************
> >> Date: Tue, 26 Aug 2003 12:35:00 -0700 (PDT)
> >> From: Cron Daemon <root@mcising.net>
> >> To: root@mcising.net
> >> Subject: Cron <root@shadow> /etc/init.d/issue
> >>
> >> TERM environment variable not set.
> >> ********************************************************
> >> Date: Tue, 26 Aug 2003 12:35:00 -0700 (PDT)
> >> From: Cron Daemon <root@mcising.net>
> >> To: root@mcising.net
> >> Subject: Cron <root@shadow> root /etc/init.d/issue
> >>
> >> /bin/sh: line 1: root: command not found
> >> ********************************************************
> >>
> >> Any suggestions would be greatly appriciated.
> >>
> >> _______________________________________________
> >> vox-tech mailing list
> >> vox-tech@lists.lugod.org
> >> http://lists.lugod.org/mailman/listinfo/vox-tech
> >
> > _______________________________________________
> > vox-tech mailing list
> > vox-tech@lists.lugod.org
> > http://lists.lugod.org/mailman/listinfo/vox-tech
>=20
>=20
> --
> No PGP signature because I'm far from home and sending via webmail.
>=20
>=20
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
>=20
>=20
--=20
I usually have a GPG digital signature included as an attachment.
See http://www.gnupg.org/ for info about these digital signatures.
My key was last signed 6/10/2003. If you use GPG, *please* see me about=20
signing the key. ***** My computer can't give you viruses by email. ***
--4Ckj6UjgE2iN1+kY
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD4DBQA/TCJklHapveKyytERAlKZAJjTKO2wJi01c3V3CtPCEYfk1VjAAJ4h2Cp3
HvLDzSPa44LWShehrzjgkw==
=wSd7
-----END PGP SIGNATURE-----
--4Ckj6UjgE2iN1+kY--