Difference between revisions of "Monthly Report for User Usage"

From Define Wiki
Jump to navigation Jump to search
(Created page with "<syntaxhighlight> #!/bin/bash # Get the current time and the time one month ago CUR_TIME=`date +"%Y/%m/%d/%H:%M"` LAST_MONTH=`date --date="last month" +"%Y/%m/%d/%H:%M"` # Get the list...")
 
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
 
         fi
 
         fi
  
 +
        echo $USER,
 
         bacct -C $LAST_MONTH,$CUR_TIME -u $USER;
 
         bacct -C $LAST_MONTH,$CUR_TIME -u $USER;
 +
        echo
 
done
 
done
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 16:20, 5 December 2012

#!/bin/bash

# Get the current time and the time one month ago
CUR_TIME=`date +"%Y/%m/%d/%H:%M"`
LAST_MONTH=`date --date="last month" +"%Y/%m/%d/%H:%M"`

# Get the list of the users to run bacct against
USERS=(`ls /home`);

for USER in ${USERS[@]}
do
        if [ "$USER" == "lsfadmin" -o "$USER" == "lost+found" ]; then
                continue
        fi

        echo $USER,
        bacct -C $LAST_MONTH,$CUR_TIME -u $USER;
        echo
done