maxthedork
MIS
So I have this script and this is what it does:
That last line is all the information I need. Now, when I run it this is the kind of information I get in the sessions.log file:
Wed Sep 2 14:04:06 EDT 2009
Active sessions on {webportal-2}: 97
Active sessions on {resourceserver}: 0
Active sessions on {webportal-1}: 96
Total number of active sessions: 193
Wouldn't it be neat if I could set that in a CRON job to run every 15 minutes and log the number of active sessions so I could have a history? Yes! However, when I put it into crontab:
*/15 * * * * /home/luminis/scripts/active > /dev/null 2>&1
Yes it does in fact run every 15 minutes and it does everything... except the last line. It looks like this in the log:
Wed Sep 2 14:15:01 EDT 2009
And that's it. So I checked the sudoers file and added the command /opt/luminis/cptool for the currently logged in user, but it still doesn't do anything after adding the entry. (Yes I used visudo to edit sudoers)
Is there something I need to do to get the edited sudoers file to take effect? Or is there something else I'm missing?
thanks in advance!
Code:
#!/bin/sh
#
# Active Sessions - displays number of active sessions and puts
# a new entry into a log file.
#
# Adds a line (for readability) and datestamp into log
echo '' >> /home/luminis/scripts/sessions.log
date >> /home/luminis/scripts/sessions.log
# Checks active sessions and only reports back on the numbers
# (without grep command, it will also log all active sessions by
# username)
cptool list sessions | grep ctive >> /home/luminis/scripts/sessions.log
That last line is all the information I need. Now, when I run it this is the kind of information I get in the sessions.log file:
Wed Sep 2 14:04:06 EDT 2009
Active sessions on {webportal-2}: 97
Active sessions on {resourceserver}: 0
Active sessions on {webportal-1}: 96
Total number of active sessions: 193
Wouldn't it be neat if I could set that in a CRON job to run every 15 minutes and log the number of active sessions so I could have a history? Yes! However, when I put it into crontab:
*/15 * * * * /home/luminis/scripts/active > /dev/null 2>&1
Yes it does in fact run every 15 minutes and it does everything... except the last line. It looks like this in the log:
Wed Sep 2 14:15:01 EDT 2009
And that's it. So I checked the sudoers file and added the command /opt/luminis/cptool for the currently logged in user, but it still doesn't do anything after adding the entry. (Yes I used visudo to edit sudoers)
Is there something I need to do to get the edited sudoers file to take effect? Or is there something else I'm missing?
thanks in advance!