Questions and Answers
Amy Rich
In the December issue, one of the questions covered modifying root's crontab
using scp and ssh. In order for the supplied script to work correctly, each
command after the ssh needs to be quoted so that it is not executed on
the local machine instead of the intended target machine. Thanks to Josh Simon
for catching this error. The corrected script should be:
#!/bin/sh
for i in host1 host2 host2 host4; do
scp master.cron root@${i}:/location/to/crontab/file
ssh root@${i} "chmod 0400 /location/to/crontab/file;" \
"chown root /location/to/crontab/file;" \
"crontab /location/to/crontab/file;" \
"crontab -l"
Q I'm running Solaris 9 on a V880, and I'm having
an issue with a script running from cron. The script is a slightly modified version
of the updatedb script that comes with locate. Here's my version
of the script (available at http://www.gnu.org/licenses/licenses.html#GPL)
with all of the comments and copyright information edited out for simplicity's
sake:
#!/bin/sh
usage="\
Usage: updatedb [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...']
[--prunepaths='dir1 dir2...'] [--output=dbfile] [--netuser=user]
[--old-format] [--version] [--help]"
old=no
for arg
do
opt='echo $arg|sed 's/^\([^=]*\).*/\1/''
val='echo $arg|sed 's/^[^=]*=\(.*\)/\1/''
case "$opt" in
--localpaths) SEARCHPATHS="$val" ;;
--netpaths) NETPATHS="$val" ;;
--prunepaths) PRUNEPATHS="$val" ;;
--output) LOCATE_DB="$val" ;;
--netuser) NETUSER="$val" ;;
--old-format) old=yes ;;
--version) echo "GNU updatedb version 4.1"; exit 0 ;;
--help) echo "$usage"; exit 0 ;;
*) echo "updatedb: invalid option $opt
$usage" >&2
exit 1 ;;
esac
done
: ${SEARCHPATHS="/"}
: ${NETPATHS=}
: ${PRUNEPATHS="/tmp /usr/tmp /var /users /usr/local/src \
/root /proc /dev /devices /data/amanda"}
test -z "$PRUNEREGEX" &&
PRUNEREGEX='echo $PRUNEPATHS|sed -e 's,^,\\\(^,' -e 's, \
,$\\\)\\\|\\\(^,g' -e 's,$,$\\\),''
: ${LOCATE_DB=/usr/local/var/locatedb}
if test -d /root/tmp; then
: ${TMPDIR=/root/tmp}
else
: ${TMPDIR=/tmp}
fi
: ${NETUSER=daemon}
: ${LIBEXECDIR=/usr/local/libexec}
: ${BINDIR=/usr/local/bin}
: ${find=find}
: ${frcode=frcode}
: ${bigram=bigram}
: ${code=code}
PATH=$LIBEXECDIR:$BINDIR:/usr/ucb:/bin:/usr/bin:$PATH export PATH
if test $old = no; then
{
if test -n "$SEARCHPATHS"; then
$find $SEARCHPATHS \
\( -fstype nfs -o -fstype NFS -o -type d -regex "$PRUNEREGEX" \) \
-prune -o -print
fi
if test -n "$NETPATHS"; then
su $NETUSER -c \
"$find $NETPATHS \\( -type d -regex \"$PRUNEREGEX\" -prune \\) \
-o -print"
fi
} | sort -f | $frcode > $LOCATE_DB.n
|