IBM IntelliStation POWER 285 Technical Overview And Introduction page 54

Hide thumbs Also See for IntelliStation POWER 285:
Table of Contents

Advertisement

The Perl script in Example 4-3 can perform power management. The program computes the
power-on date and time at the actual shutdown time. For example, the shutdown of the
system is on Friday at 6:00 p.m,. the script calculates the power-on date scheduled to next
Monday at 6:00 a.m. In summary, 60 hours of energy saving can be achieved.
Example 4-3 Power off and on script
*****************************************************************************************
IBM DOES NOT WARRANT OR REPRESENT THAT THE CODE PROVIDED IS COMPLETE OR UP-TO-DATE. IBM
DOES NOT WARRANT, REPRESENT OR IMPLY RELIABILITY, SERVICEABILITY OR FUNCTION OF THE CODE.
IBM IS UNDER NO OBLIGATION TO UPDATE CONTENT NOR PROVIDE FURTHER SUPPORT. ALL CODE IS
PROVIDED "AS IS," WITH NO WARRANTIES OR GUARANTEES WHATSOEVER.
*****************************************************************************************
#!/usr/bin/perl -w
#-------------------------------------------------------------------
# Created by Gregor Linzmeier, IBM Deutschland GmbH
#
#
#
#-------------------------------------------------------------------
#
#-------------------------------------------------------------------
# Define Start hour and minute
#-------------------------------------------------------------------
$S_HOUR=6;
$S_MIN=0;
#-------------------------------------------------------------------
# Calculate current day and time
#-------------------------------------------------------------------
$now=time;
($sec,$min,$hour,$C_DAY,$C_MON,$C_YEAR,$wday)=(localtime($now))[0,1,2,3,4,5,6];
$C_YEAR=substr($C_YEAR+1900,2,2);
$C_MON+=1;
$S_DOWN=sprintf("%02d%02d%02d%02d%02d",$C_MON,$C_DAY,$hour,$min,$C_YEAR);
#-------------------------------------------------------------------
# File Handling for specific holidays
#-------------------------------------------------------------------
if ( -e '/linzi/my.dat' ) {
print "File exists!\n";
open DAT,'/linzi/my.dat' or die $!;
while (<DAT>) {
($F_DAY,$F_MON,$N_DAYS)=split(/ /);
if (($C_DAY == $F_DAY)&&($C_MON == $F_MON)) {
$now+=86400 * $N_DAYS;
($sec,$min,$hour,$S_DAY,$S_MON,$S_YEAR,$wday)=(localtime($now))[0,1,2,3,4,5,6];
$S_YEAR=substr($S_YEAR+1900,2,2);
$S_MON+=1;
$S_DOWN=sprintf("%02d%02d%02d%02d%02d",$S_MON,$S_DAY,$S_HOUR,$S_MIN,$S_YEAR);
close DAT;
system ("shutdown -Ft '$S_DOWN' <<EOF
yes
EOF");
exit;
}
}
}
#-------------------------------------------------------------------
# Regular weekend calculation
#-------------------------------------------------------------------
44
IBM IntelliStation POWER 285 Technical Overview and Introduction
pSeries Technical Support Workstation and entry Server
Systems and Technology Group - Northeast Europe
Version 1.0

Advertisement

Table of Contents
loading

Table of Contents