all sorts of Linux questions

skisteven1

Senior member
Jul 15, 2003
537
0
0
UPDATE: I plan to use this thread as sort of a troubleshooting area for my own (and anyone else's) general linux woes. It should be seen as a idea board of sorts, and while I'd love any help you can offer, many times I'll probably also figure it out on my own. I hope this doesn't conflict with the rules of the forum. I feel like this is a better way to go about it than making a new thread for each little problem I run into.

Anyway, so if you know what you're doing and want to help, or just want to see what I'm going through, feel free to check back every so often.


I'm getting these errors in /var/log/messages, and I'm not sure what they mean...., Any ideas?

Apr 19 03:20:05 router crond(pam_unix)[28374]: session closed for user root
Apr 19 03:25:01 router crond(pam_unix)[28376]: session opened for user root by (
uid=0)
Apr 19 03:25:04 router crond(pam_unix)[28376]: session closed for user root
Apr 19 03:30:01 router crond(pam_unix)[28378]: session opened for user root by (
uid=0)
Apr 19 03:30:04 router crond(pam_unix)[28378]: session closed for user root
Apr 19 03:35:01 router crond(pam_unix)[28380]: session opened for user root by (
uid=0)
Apr 19 03:35:04 router crond(pam_unix)[28380]: session closed for user root
Apr 19 03:40:01 router crond(pam_unix)[28382]: session opened for user root by (
uid=0)
etc....
 

skisteven1

Senior member
Jul 15, 2003
537
0
0
Another one in the mean time.

I have a script that starts out like this:
exec >> $DEST/logfile.txt
exec 2>> $DEST/errorfile.txt
#mount $SOURCE

exists_source=`mount -t smbfs | grep $SOURCE` >&1
echo "exists source: $exists_source"
if [ -z $exists_source ]
then
echo "Source not mounted"
fi

This actually works correctly. However, I get the output of "mount -t smbfs" in my logfile, and I don't want it there. Is there any way I can do the equivilent (test to see if the source is mounted) without showing it in the logfile?

Thanks!
 

skisteven1

Senior member
Jul 15, 2003
537
0
0
Well, I got the scripting thing down, though it's kind of ugly and kludge-y. It occurred to me just after I finished this that I could do something like "if [ -z grep $SOURCE /etc/mtab ]" and it would work just fine, without any of this working around -- but I guess it's too late for that :p

Here's how I managed to get it to work (Like I said, very ugly)
exec 3>&1
exec >> $DEST/logfile.txt
exec 2>> $DEST/errorfile.txt

exec >&3
exists_source=`mount -t smbfs | grep $SOURCE` #testing to see if we mounted source or not.
exec 3>&-
exec >> $DEST/logfile.txt

if [ -z "$exists_source" ]
then
echo "Source not mounted. Mounting Now."
mount $SOURCE
else
echo "Source already mounted. Proceeding..."
fi

echo "`date +%F` `date +%T%t` Starting Backup of Database files"

As a side note, after re-reading my code up here, i absolutely LOVE LOVE LOVE vim's color coding.