The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   retarded maintenance scripts (http://hintsforums.macworld.com/showthread.php?t=5578)

jpkelly 09-14-2002 04:21 AM

retarded maintenance scripts
 
I would love to know MT's findings on the new maint scripts.

I changed the crontab commands back to the old ones because I like to get the mail it sends out.
Gives me a bit of reassurance that the servers are running ok and I have even spotted and fixed some problems I spotted in the mail.
I have also added psync and rsync commands to /etc/daily.local to back up my system and mirror web pages to another machine.

bluehz 09-14-2002 09:16 AM

I don't suppose you could detail what you did to get back to the old-style maint scripts could you. I too like getting the mail.

jpkelly 09-14-2002 10:24 AM

I used Webmin to edit the crontab but you could use CronniX or whatever other method to edit crontab.

I changed

Code:

periodic daily
periodic weekly
periodic monthly

back to

Code:

sh /etc/daily        2>&1 | tee /var/log/daily.out        | mail -s "`hostname` daily output"  root
sh /etc/weekly        2>&1 | tee /var/log/weekly.out        | mail -s "`hostname` weekly output"  root
sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "`hostname` monthly output" root


enola 09-14-2002 11:23 AM

Another way to get the log mailed to you is leave the crontab as is and add a file called periodic.conf.local in your /etc directory.

Then add the following into the file:

daily_output="username"
weekly_output="username"
monthly_output="username"

Where username is your username. What this doesn't get you though is an email and output written to a file. If you want both go with jpkelly's suggestion.

mervTormel 09-14-2002 01:21 PM

enola, thanks.

seems that periodic could have scored a little better in the output flexibility dept.

perhaps some tee pipe fitting could be done somewheres to get the singular log back in /var/log and mail sent, e.g.,

daily_output="tee /var/log/daily.out root" # tee /file mailto:user

...
/usr/sbin/periodic...

case "$output" in
tee*) pipe= some crazy machinations to get tee stuffed before mail
/*) pipe="cat >>$output";;
"") pipe=cat;;
*) pipe="mail -s '$host ${arg##*/} run output' $output";;
esac
...


¡no me gusta!

enola 09-14-2002 01:41 PM

I was thinking maybe that's what "") pipe=cat;; was intended for. To generate output to be piped to whatever the user wants. So if you set

daily_output =""

You could change your crontab to something like the old style entry:

periodic daily | tee /var/log/daily.out | mail -s "`hostname` daily output" username

I haven't actually tried this but looks like it should work.

mervTormel 09-14-2002 01:46 PM

yep. you're right. heh.

::keep it stupid, simple syndrome::

thank you for your support.

bluehz 09-14-2002 06:35 PM

Am I understaning this correct....

/etc/periodic.conf.local

daily_output=""
weekly_output=""
monthly_output=""

---

/etc/crontab

periodic daily | tee /var/log/daily.out | mail -s "`hostname` daily output" root

mervTormel 09-14-2002 06:36 PM

roger. that looks copacetic.

bluehz 09-15-2002 09:29 AM

This is the e-mail I got this morning - after the first run of daily - setup as described:

"No output from the 2 files processed"

Any ideas?

Quote:

Originally posted by bluehz
Am I understaning this correct....

/etc/periodic.conf.local

daily_output=""
weekly_output=""
monthly_output=""

---

/etc/crontab

periodic daily | tee /var/log/daily.out | mail -s "`hostname` daily output" root

enola 09-15-2002 01:38 PM

I just tried this in my cron and I got the expected results. A daily.out and an email.

Try running just from the command line:

sudo periodic daily

You should get output like what shows up in the log. I'd start there for troubleshooting.

mervTormel 09-15-2002 01:41 PM

hmm, works here. is there a /var/log/daily.out? if not, i suspect your crontab line, maybe. make sure the command doen't wrap, i.e., the command has to be all on one line.

bluehz 09-15-2002 04:57 PM

Running in the CLI I get the same results:

> sudo periodic daily
> No output from the 2 files processed

/var/log/daily.out is empty

Quote:

Originally posted by enola
Try running just from the command line:

sudo periodic daily

You should get output like what shows up in the log. I'd start there for troubleshooting.
I noticed in the /periodic/* files they both start with:

if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi

Inside the /etc/defaults/periodic.conf file it shows that /etc/periodic.conf.local overides variables in /etc/defaults/. My /etc/periodic.conf/local contains nothing but this:

daily_output=""
weekly_output=""
monthly_output=""

I am not seeing where or how the mechanism works to create and send the output.

enola 09-15-2002 05:21 PM

Do you have a /etc/defaults/periodic.conf file? There is a line in there for overriding the values:

Code:

# What files override these defaults ?
periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local"

So either two would work for overriding. Okay so let's take the periodic wrapper out of the picture. Just run the script by itself.

sudo /etc/daily

Do you get output? I just ran like this and get the normal output. Have you edited the daily script at all? Something is funky.

bluehz 09-15-2002 05:24 PM

Trying that as we speak:

Just manually ran daily.local. Terminal shows a good output up to the locate.updatedb stuff. Then and error:

Updating the Locate db:
/usr/libexec/locate.updatedb: line 45: syntax error near unexpected token `setenv'
/usr/libexec/locate.updatedb: line 45: `if (! $?TMPDIR) setenv TMPDIR /var/tmp'

I remember reading there was a syntax error there and a solution - but for the life of me I can not locate that info now!

mervTormel 09-15-2002 05:25 PM

Quote:

Originally posted by bluehz
Inside the /etc/defaults/periodic.conf file it shows that /etc/periodic.conf.local overides variables in /etc/defaults/. My /etc/periodic.conf/local contains nothing but this:

daily_output=""
weekly_output=""
monthly_output=""

I am not seeing where or how the mechanism works to create and send the output.
My /etc/periodic.conf/local ?

you mean /etc/periodic.conf.local ?

at the end of /etc/defaults/periodic.conf , a function is defined for slurping up the
/etc/periodic.conf.local file.

if you are out of rev on any of the vanilla periodic files, i suggest you get them back to vanilla and try again.

all periodic files should be vanilla, and you should create one file,

/etc/periodic.conf.local

containing daily_output=""

for now.

mervTormel 09-15-2002 05:39 PM

45 if (! $?TMPDIR) setenv TMPDIR /var/tmp

no syntax error here. are you talking about the term_program syntax error?

"There is a typo in /usr/share/tcsh/examples/aliases..."

http://www.macosxhints.com/article.p...20826003806202

different thing altogether.

are you running stock csh ? or have you managed to skronk that, too?

enola 09-15-2002 05:42 PM

Quote:

Originally posted by bluehz
Just manually ran daily.local.
Okay, I take it by this that you've got a /etc/daily and a /etc/daily.local. Go with mT's advice and go back to a vanilla setup. Rename daily.local to something else so that it doesn't get called by /etc/daily and that things finish correctly.

jpkelly 09-16-2002 09:54 AM

got this in the mail today:
From daily output
Subject: crabtree daily run output

Removing scratch and junk files:
rm: ./Mount01: is a directory
rm: ./Mount02: is a directory
rm: ./Mount03: is a directory
rm: ./Mount04: is a directory
rm: ./zBooterMnt: is a directory

What does it mean?

bluehz 09-16-2002 10:25 AM

Virgin install and everything seems to be working now. Got the e-mail and all. Thanks guys for the help.

FYI - I also see the:

Removing scratch and junk files:
rm: ./Mount01: is a directory
rm: ./Mount02: is a directory
rm: ./Mount03: is a directory
rm: ./Mount04: is a directory
rm: ./zBooterMnt: is a directory

mervTormel 09-16-2002 11:28 AM

"fsck it, drive on"

jpkelly 09-16-2002 03:36 PM

OK I already know the answer to this one. (man fsck)
How exactly does one fsck it?
Is there a fsck for dummies?

mervTormel 09-16-2002 04:18 PM

uh, you misinterpreted my meaning :D

rephrasing: eff it, drive on...

the "rm: ./Mount01: is a directory" errors are due to brain damage somewhere, but, since those dirs are empty, it's not very interesting.

there are some other problems with the daily cleaner code...
Code:

if [ -d /var/tmp ]; then
    cd /var/tmp && {
    find . -fstype local ! -name . -atime +7 -ctime +3 -exec rm -f -- {} \;
    find -fstype local -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
        >/dev/null 2>&1; }
fi

that first find causes the rm errors on dirs. and the second find is just plain wrong...

$ /usr/bin/find -fstype local -d .
stype: -d: unknown option

even reduction doesn't help...

$ /usr/bin/find -fstype local .
stype: stype: No such file or directory
stype: local: No such file or directory
.
./3d84c825109b0
...

since the objective of the second find is to rmdir, i think it should read...

$ /usr/bin/find . -fstype local -type d ! -name . # and so on...
./mds
./Mount01
./Mount02
./Mount03
./Mount04
./vi.recover
./zBooterMnt

but, i'll just let her buck...

mervTormel 09-16-2002 04:55 PM

hmm, after looking at the tmp cleaner code, i thought that it is all brain damaged, so i hacked on it...
Code:

if [ -d /tmp ]; then
    cd /tmp && {

# bdd; 16sep02; attempt to fix this tripe
#  find . -fstype local -type f -atime +3 -ctime +3 -exec rm -f -- {} \;
#  find -fstype local -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
   
    find . -fstype local -type f -atime +3 -ctime +3 -exec rm -f -- {} \; 
    find . -fstype local -type d ! -name . -mtime +1 -exec rmdir -- {} \; \
        >/dev/null 2>&1; }
fi

if [ -d /var/tmp ]; then
    cd /var/tmp && {

# bdd; 16sep02; attempt to fix this tripe
#  find . -fstype local ! -name . -atime +7 -ctime +3 -exec rm -f -- {} \; 
#  find -fstype local -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
   
    find . -fstype local -type f -atime +7 -ctime +3 -exec rm -f -- {} \; 
    find . -fstype local -type d ! -name . -mtime +1 -exec rmdir -- {} \; \
        >/dev/null 2>&1; }
fi

i think that might begin to start to approach ever closer to almost the right thing.

if you mod your daily script, be sure to save the original distribution...

$ sudo cp -p /etc/periodic/daily/500.daily /etc/periodic/daily/500.daily.10.2.dist

jpkelly 09-16-2002 09:12 PM

well that seemed to get rid of the offending dirs...
I had considered changing the 'rm -f' part to 'rm -rf' but that probably would not have been a good idea.


All times are GMT -5. The time now is 06:12 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.