LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Suspend issue (http://www.linuxquestions.org/questions/slackware-14/suspend-issue-801662/)

coolgreen1 04-12-2010 10:07 PM

Suspend issue
 
Hi,

I am running Slackware64 13.0 and am really enjoying it so far, except for one issue. Everytime I try to suspend to RAM using the "Suspend to RAM" button in KDE, my screen will go blank and then to sleep, but the computer will not. It will just hang and continue to run the fans, lights and USB. Nothing I press will resume it. I am forced to hard reboot my computer at this point. I am part of the group "power." How can I fix this problem.

Here is the output of lspci if that helps:

Code:

00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller (rev 02)                                                                     
00:01.0 PCI bridge: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port (rev 02)                                                                 
00:1a.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 02)                                                                 
00:1a.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 02)                                                                 
00:1a.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 02)                                                                 
00:1a.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 02)                                                               
00:1c.0 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 (rev 02)
00:1c.4 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 5 (rev 02)
00:1c.5 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 6 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 92)
00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 port SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
00:1f.5 IDE interface: Intel Corporation 82801I (ICH9 Family) 2 port SATA IDE Controller (rev 02)
01:00.0 VGA compatible controller: nVidia Corporation G70 [GeForce 7800 GTX] (rev a1)
02:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8056 PCI-E Gigabit Ethernet Controller (rev 12)
03:00.0 SATA controller: JMicron Technology Corp. 20360/20363 Serial ATA Controller (rev 03)
03:00.1 IDE interface: JMicron Technology Corp. 20360/20363 Serial ATA Controller (rev 03)
05:01.0 Multimedia audio controller: Creative Labs SB Audigy (rev 04)
05:01.1 Input device controller: Creative Labs SB Audigy Game Port (rev 04)
05:01.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port (rev 04)
05:03.0 FireWire (IEEE 1394): Agere Systems FW322/323 (rev 70)
05:04.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

Any help would be greatly appreciated.

rfernandez 04-12-2010 11:02 PM

Have you tried

Code:

# pm-suspend
as root? Does it works? What is the output of /var/log/pm-suspend.log ?

dolphin77 04-13-2010 12:48 AM

Hi,

not sure the root of your problem is the same as I had. But for any case.

I have ATI. And there was a problem with acpi video module which hooked my system exactly as you describe (besides the fact that you have Nvidia).

What I did is tried to manually to remove video module.

rmmod video

After that pm-suspend started to work as it should. To automate the process I added video module to /etc/pm/config.d/unload_modules:
SUSPEND_MODULES="video"

and everything started to work automatically.

But now I run 2.6.34-rc3-git10 and for this kernel there is no need anymore to do something similar. Everything already works. It looks like 2.6.34 will bring a lot of improvements to ACPI support.

regards,
Vladimir

coolgreen1 04-13-2010 01:00 AM

Quote:

Originally Posted by rfernandez (Post 3933583)
Have you tried

Code:

# pm-suspend
as root? Does it works? What is the output of /var/log/pm-suspend.log ?

Hi,

Thank you for your reply. When I ran
Code:

pm-suspend
as root but it did not work. I got the same results as the original issue. Here is the out put of /var/log/pm-suspend.log.
Code:

Initial commandline parameters:                       
Tue Apr 13 01:51:25 EDT 2010: Running hooks for suspend.
/usr/lib64/pm-utils/sleep.d/00auto-quirk suspend suspend: Adding quirks from HAL: --quirk-dpms-on --quirk-dpms-suspend --quirk-vbe-post --quirk-vbemode-restore --quirk-vbestate-restore --quirk-vga-mode-3                                   
success.                                                                       
/usr/lib64/pm-utils/sleep.d/00logging suspend suspend: Linux HyPeR-TuX 2.6.29.6 #3 SMP Mon Dec 7 15:01:06 CST 2009 x86_64 Intel(R) Core(TM)2 CPU          6320  @ 1.86GHz GenuineIntel GNU/Linux                                               
Module                  Size  Used by                                         
snd_seq_dummy          3172  0                                               
snd_seq_oss            33536  0                                               
snd_seq_midi_event      7264  1 snd_seq_oss                                   
snd_seq                56320  5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event   
snd_pcm_oss            42976  0                                               
snd_mixer_oss          16768  1 snd_pcm_oss                                   
ipv6                  288704  18                                               
pcmcia                36824  0                                               
pcmcia_core            36804  1 pcmcia                                         
ppdev                  8488  0                                               
lp                    11972  0                                               
parport_pc            28200  0                                               
parport                36752  3 ppdev,lp,parport_pc                           
fuse                  60096  3                                               
snd_emu10k1          150944  2                                               
snd_rawmidi            22784  1 snd_emu10k1                                   
snd_ac97_codec        121496  1 snd_emu10k1                                   
ac97_bus                1920  1 snd_ac97_codec                                 
snd_pcm                80872  3 snd_pcm_oss,snd_emu10k1,snd_ac97_codec         
snd_seq_device          7188  5 snd_seq_dummy,snd_seq_oss,snd_seq,snd_emu10k1,snd_rawmidi                                                                     
snd_timer              22256  3 snd_seq,snd_emu10k1,snd_pcm                   
snd_page_alloc          9616  2 snd_emu10k1,snd_pcm                           
snd_util_mem            3968  1 snd_emu10k1                                   
snd_hwdep              8456  1 snd_emu10k1                                   
snd                    65000  15 snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_emu10k1,snd_rawmidi,snd_ac97_codec,snd_pcm,snd_seq_device,snd_timer,snd_hwdep
soundcore              7168  1 snd                                           
emu10k1_gp              3232  0                                               
rtl8187                44576  0                                               
gameport              11696  2 emu10k1_gp                                     
mac80211              171288  1 rtl8187                                       
r8169                  37860  0                                               
mii                    5216  1 r8169                                         
i2c_i801              10400  0                                               
intel_agp              30960  0
eeprom_93cx6            2208  1 rtl8187
sky2                  53060  0
cfg80211              42064  2 rtl8187,mac80211
evdev                  11392  12
rtc_cmos              11928  0
rtc_core              19652  1 rtc_cmos
rtc_lib                2880  1 rtc_core
thermal                18880  0
button                  7328  0
serio_raw              6116  0
processor              43960  1 thermal
thermal_sys            13088  2 thermal,processor
hwmon                  2728  1 thermal_sys
sg                    29920  0
            total      used      free    shared    buffers    cached
Mem:      3084208    755736    2328472          0      75824    276548
-/+ buffers/cache:    403364    2680844
Swap:      6000004          0    6000004
success.
/usr/lib64/pm-utils/sleep.d/00powersave suspend suspend: success.
/usr/lib64/pm-utils/sleep.d/01grub suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/49bluetooth suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/55NetworkManager suspend suspend: success.
/usr/lib64/pm-utils/sleep.d/75modules suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/90clock suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/94cpufreq suspend suspend: success.
/usr/lib64/pm-utils/sleep.d/95led suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/98smart-kernel-video suspend suspend: not applicable.
/usr/lib64/pm-utils/sleep.d/99video suspend suspend: kernel.acpi_video_flags = 0
Allocated buffer at 0x11000 (base is 0x0)
ES: 0x1100 EBX: 0x0000
success.
Tue Apr 13 01:51:27 EDT 2010: performing suspend


coolgreen1 04-13-2010 01:03 AM

Quote:

Originally Posted by dolphin77 (Post 3933657)
Hi,

not sure the root of your problem is the same as I had. But for any case.

I have ATI. And there was a problem with acpi video module which hooked my system exactly as you describe (besides the fact that you have Nvidia).

What I did is tried to manually to remove video module.

rmmod video

After that pm-suspend started to work as it should. To automate the process I added video module to /etc/pm/config.d/unload_modules:
SUSPEND_MODULES="video"

and everything started to work automatically.

But now I run 2.6.34-rc3-git10 and for this kernel there is no need anymore to do something similar. Everything already works. It looks like 2.6.34 will bring a lot of improvements to ACPI support.

regards,
Vladimir

Hi,

Thank you for your reply. I tried to
Code:

rmmod video
but it says it is not in /proc/modules. I also tried
Code:

rmmod nv
and
Code:

rmmod nividia
with the same results. Here is the output of /proc/modules if that helps:

Code:

snd_seq_dummy 3172 0 - Live 0xffffffffa0292000                 
snd_seq_oss 33536 0 - Live 0xffffffffa0284000                   
snd_seq_midi_event 7264 1 snd_seq_oss, Live 0xffffffffa027d000 
snd_seq 56320 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi_event, Live 0xffffffffa026a000                                                                         
snd_pcm_oss 42976 0 - Live 0xffffffffa025a000                                 
snd_mixer_oss 16768 1 snd_pcm_oss, Live 0xffffffffa0250000                     
ipv6 288704 18 - Live 0xffffffffa0204000                                       
pcmcia 36824 0 - Live 0xffffffffa01f6000                                       
pcmcia_core 36804 1 pcmcia, Live 0xffffffffa01e8000                           
ppdev 8488 0 - Live 0xffffffffa01be000                                         
lp 11972 0 - Live 0xffffffffa01b6000                                           
parport_pc 28200 0 - Live 0xffffffffa01aa000                                   
parport 36752 3 ppdev,lp,parport_pc, Live 0xffffffffa019c000                   
fuse 60096 3 - Live 0xffffffffa0188000                                         
snd_emu10k1 150944 2 - Live 0xffffffffa015e000                                 
snd_rawmidi 22784 1 snd_emu10k1, Live 0xffffffffa0153000                       
snd_ac97_codec 121496 1 snd_emu10k1, Live 0xffffffffa0130000
ac97_bus 1920 1 snd_ac97_codec, Live 0xffffffffa012a000
snd_pcm 80872 3 snd_pcm_oss,snd_emu10k1,snd_ac97_codec, Live 0xffffffffa0111000
snd_seq_device 7188 5 snd_seq_dummy,snd_seq_oss,snd_seq,snd_emu10k1,snd_rawmidi, Live 0xffffffffa010a000
snd_timer 22256 3 snd_seq,snd_emu10k1,snd_pcm, Live 0xffffffffa00ff000
snd_page_alloc 9616 2 snd_emu10k1,snd_pcm, Live 0xffffffffa00f7000
snd_util_mem 3968 1 snd_emu10k1, Live 0xffffffffa00bb000
snd_hwdep 8456 1 snd_emu10k1, Live 0xffffffffa00f2000
emu10k1_gp 3232 0 - Live 0xffffffffa007e000
snd 65000 15 snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_emu10k1,snd_rawmidi,snd_ac97_codec,snd_pcm,snd_seq_device,snd_timer,snd_hwdep, Live 0xffffffffa00e0000
gameport 11696 2 emu10k1_gp, Live 0xffffffffa00ab000
soundcore 7168 1 snd, Live 0xffffffffa001e000
sky2 53060 0 - Live 0xffffffffa00d1000
r8169 37860 0 - Live 0xffffffffa00c2000
mii 5216 1 r8169, Live 0xffffffffa00be000
i2c_i801 10400 0 - Live 0xffffffffa00b6000
intel_agp 30960 0 - Live 0xffffffffa00a1000
rtc_cmos 11928 0 - Live 0xffffffffa009c000
thermal 18880 0 - Live 0xffffffffa0095000
rtc_core 19652 1 rtc_cmos, Live 0xffffffffa008e000
rtc_lib 2880 1 rtc_core, Live 0xffffffffa0011000
rtl8187 44576 0 - Live 0xffffffffa0081000
processor 43960 1 thermal, Live 0xffffffffa0071000
mac80211 171288 1 rtl8187, Live 0xffffffffa0042000
eeprom_93cx6 2208 1 rtl8187, Live 0xffffffffa003f000
evdev 11392 12 - Live 0xffffffffa0037000
cfg80211 42064 2 rtl8187,mac80211, Live 0xffffffffa002a000
thermal_sys 13088 2 thermal,processor, Live 0xffffffffa0021000
button 7328 0 - Live 0xffffffffa001a000
hwmon 2728 1 thermal_sys, Live 0xffffffffa0014000
serio_raw 6116 0 - Live 0xffffffffa000d000
sg 29920 0 - Live 0xffffffffa0000000


dolphin77 04-13-2010 10:10 AM

yep, looks like your problem is totally different.

Maybe something like this will work for you?:
http://lists.mandriva.com/bugs/2010-03/msg01219.php

rfernandez 04-14-2010 12:04 AM

Uhm, what about your "dmesg" and "# cat /var/log/syslog" output after tring to suspend?

ROXR 04-15-2010 02:04 AM

Hello, try with this script who I use when my kde suspend mode not work

Code:

#!/bin/sh
# Release version: 1.11/Jan 01/2010
# /usr/bin/s2 -- offers some flexibility when locking/suspending your desktop.
# Does not use any LRMI or PCI-register weirdness-- this script is intended
# for machines with non-crappy BIOSes and proper ACPI implementations.
#
# Copyright (C) <2009> <Sasha Alexandr> <crawlingwithsnakes at hush dot com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
# Testing done on: Slackware 11.0 - kernel 2.6.30
# Testing done on: Slack64-current  kernel=2.6.30.5
# Testing done on: Slack64-13.0    kernel=2.6.32.2
# Testing hardware: MSI P6N-SLI-FI (MS-7350)
# Intel E2160 Core2 CPU
# nVidia chipset MCP51/430i BIOS 2.7
# Ethernet: Realtek 8211BL using forcedeth driver.
# Video: 2x eVGA eGeForce 7300/7200 PCI-E cards.
# Video: nVidia binary version 185.18.31
# DE: KDE 3.5.4 & xscreensaver for locking session.
# DE: XFCE in Slack64-current & xscreensaver for locking session
#--proposed changes:    ------------------------------------
#--test 'suspend to disk' support (I don't use it yet)
#------------------------------------------------------------
#--<changelog:>    -----------------------------------------
# v1.01  - adjust 'Usage:' text; tidy some code.
#        - support _list_ of NICs; add logging yes/no option
#        - divert net-restart output to $console
# v1.02  - clean up some junk that was outputting to console
#        - clarify comments & Usage:
#        - adjustable args for net & session-lock
#        - add a bit more sanity checking.
# v1.03  - fix more unwanted junk coming on screen after wake-up.
# v1.04  - kill undead backgrounded process when cancel suspend
#        - remove one function; put that code elsewhere.
# v1.05  - shorten help-page console output horizontal chars.
#        - clean code a bit.
# v1.10  - adjust/test for Slack64-current
#        - clean code more.
#        - rename to /usr/bin/s2
# v1.11  - fixed up for POSIX compliance and/or shells other than Bash.
#        - cleaned up console output a bit so it doesn't scroll a mile down screen.
#--</changelog>
#-------------------------------------------------------------
#--<known bugs:>
# IF X is not running, using this script from a VT may result in no video
# after resuming. X can then still be started normally (blindly) but the VT's
# seem to remain unusable. I may need to add some vbetool functionality
# to turn the video back on.
#--</known bugs>
#------------------------------------------------------------
setup () {
#-------------------------------adjustable stuff-------------
# unplug/reinsert any kernel modules you've determined
# cause problems suspending/resuming on your machine.
# If you use the hangcheck-timer, it MUST be a module and
# it MUST be removed before suspend, reinserted after resume.
# If hangcheck-timer is built static into the kernel, suspend
# will only work once; subsequent suspends will resume
# immediately all by themselves.
unplug_list="ohci_hcd forcedeth hangcheck-timer"
insert_list="ohci_hcd forcedeth" # if empty, unplug list is used
want_to_log_the_process='y' # change to y to log the suspend
# separate multiple NICs below with spaces like 'eth0 eth1'
# NICs using DHCP:
NIC='eth0' # stop this/these before suspending to ram/disk
#------------------------------non-adjustable stuff-----------
suspend2_log=/var/log/suspend2.log
log_pidfile=/var/run/suspend2_logpid
fork_pidfile=/var/run/suspend2_forkpid
pm_debug_exist=/sys/power/pm_test
version='1.11'
#--------------------------------adjustable stuff-------------
# Common paths to stuff - verify/adjust for your system:
kernel_log=/var/log/kernel
modprobe=/sbin/modprobe
hwclock=/sbin/hwclock
tail=/usr/bin/tail
ifconfig=/sbin/ifconfig
net_init_script=/etc/rc.d/rc.inet1
net_init_script_arg='restart'
session_locker=/usr/X11R6/bin/xscreensaver-command
session_locker_arg='-lock'
console=/dev/tty1
#--------------------------------------------pm debug---------
 debug_pm_does_exist () {
  # To test/debug your system's suspend abilities, read the kernel
  # documentation about enabling/using CONFIG_PM_DEBUG
  # note: only one line must be uncommented at any time.
  #
  echo none > /sys/power/pm_test # really suspend (default)
  #echo freezer > /sys/power/pm_test # least invasive test
  #echo devices > /sys/power/pm_test # test device susp/resume
  #echo platform > /sys/power/pm_test # only w/suspend to disk
  #echo processors > /sys/power/pm_test # test CPU susp/resume
  #echo core > /sys/power/pm_test # most invasive test
 }
[ -f $pm_debug_exist ] && debug_pm_does_exist
#---------------------------------------------end pm debug-----
} # end setup
# Do not edit below here unless you know what you're doing.
#--------------------------------------------------------------

usage () {
 unset list
  printf "\n s2: a suspend script by Sasha. Version $version (Dec 2009)\n"

  [ "$1" = 'error' ] && printf " Error: bad, missing, or extra parameter.\n"
  for i in standby mem disk; do
    [ "$(echo $methods | grep -o $i)" ] && eval $i='1' || unset i
  done;
cat << USAGE_END
 Usage:

 To suspend immediately, just specify the type of suspend you want, and
 optionally the 'lock' option, which locks your desktop session before
 suspending. If you want the machine to automatically suspend at a later time
 then use the additional options. All options are:

 -x | cancel    to abort any pending suspends.
 -l | lock      locks the desktop session before suspending.
 -m | mem      indicates you want 'suspend to ram'
 -d | disk      indicates you want 'suspend to disk'
 -s | standby  indicates you want 'suspend to standby'
  ? | status    shows any current pending suspend operation.
 inmins=mm      will cause a suspend after mm minutes.
 insecs=ss      causes a suspend after ss seconds.
 inhrs=hh      will suspend after hh hours.
 time=HHMM      allows a HHMM format of time-of-day to suspend at.
                NOTE: due to the nature of the "date" system command
                some adjustment is done depending on the time entered.
                If you get unsatisfactory results with the time=HHMM option
                give me an example and description of what happened and I will
                look into it.

 When a suspend instance has been created, you will see on the screen, an
 informational line, showing the actual command used to perform the operation,
 such as:

 Running s2 process: (18203) /bin/sh /usr/bin/s2 fork mem 7200 unlocked

 Above, the (18203) is the process ID of the running instance. The remainder of
 the line can be copied as-is, and used to silently start an s2 instance from
 cron or other means.

 As of this writing (version 1.1x), suspend to disk has not been tested by me
 at all. It should work fine-- it's reputed to be less troublesome than
 suspending to ram. Standby and suspend to ram both work on my system.
 If you find a bug, i.e. something really dumb/obvious that I missed, point it
 out and I'll fix it.

 If you're so inclined, you can run this from a crontab or an icon/kicker
 button with a command something like: kdesu /path/to/script <args>

 Below shows what suspend methods are currently available on your machine
 and the rest of the possible arguments that s2 accepts:

USAGE_END

 printf " Usage: $(basename $0) $( [ "$standby" ] && list="standby"; [ "$mem" ] && list="$list mem"; [ "$disk" ] && list="$list disk"; echo "$list" | sed 's/^[ ]//;s/ /|/g' ) [lock] [inmins=mm | insecs=ss | inhours=hh | time=HHMM]\n"
 printf " Usage: $(basename $0) [cancel] [status] [help]\n\n"
 exit 1
}

logging () {
[ "$want_to_log_the_process" = 'n' ] && return
case $1 in
  start) $tail -f $kernel_log > $suspend2_log &
        echo $! > $log_pidfile ;;
  stop) if [ -f $log_pidfile ]; then
        deadlog=$(cat $log_pidfile)
        kill $deadlog > /dev/null 2>&1 &
        wait
        fi
        ;;
esac;
}

get_jobs () {
unset fpid running_jobs
if [ -f $fork_pidfile ]; then
 fpid=$(cat $fork_pidfile); running_jobs=$(ps -p $fpid -o command= )
fi;
}

message () {
[ "$1" = 'S' ] && printf "\n$(date) ($(basename $0): Going into $action-sleep now.)\n" > $console
[ "$1" = 'R' ] && printf "\n$(date) ($(basename $0): Waking up now.)\n" > $console
}

do_standby () {
sleep $seconds; sync; sleep 1
# 'standby' doesn't need any module-unplugging.
# I switch to vt1 just for the status messages.
chvt 1; message S
[ "$lock" = 'lock' ] && $session_locker $session_locker_arg >/dev/null 2>&1
logging start
echo standby > /sys/power/state

# resuming now:

$hwclock --hctosys
message R
logging stop
chvt 7
rm -f $log_pidfile $fork_pidfile
} # end of 'do_standby'

do_suspend () {
sleep $seconds
sync; sleep 1
chvt 1; message S; sleep 2 # (legacy?) change to non-X console to prevent corrupt video
[ "$lock" = 'lock' ] && $session_locker $session_locker_arg >/dev/null 2>&1
logging start
# take down NIC(s) (optional - we restart whole network anyway later)
interface_list="$(echo $interfaces | sed 's/[ ]/\n/g')"
for NICs in $(printf "$NIC"); do
  $ifconfig $NICs down
done;
# unplug modules known to give problems:
for mod in $unplug_list; do
  [ "$(lsmod | grep $mod)" ] && $modprobe -r $mod 2>/dev/null
done;
echo $action > /sys/power/state

# Resuming now;

$hwclock --hctosys # adjust OS clock
message R
# reinsert removed modules
[ ! "$insert_list" ] && insert_list="$unplug_list"
for mod in $insert_list; do
  $modprobe $mod 2>/dev/null
done;
sleep 1 # let things settle
# Kill any running dhcpcd & restart networking as during a cold boot:
[ "$(ps ax | grep dhcpcd)" ] && killall -q dhcpcd
$net_init_script $net_init_script_arg > $console
logging stop
chvt 7
rm -f $log_pidfile $fork_pidfile
} # end of 'do_suspend'

# Script entry point:

setup

if [ "$1" = 'fork' ]; then
# we're the forked, already-configured instance:
 seconds=$3; lock=$4;
 case $2 in
  standby)
        do_standby & >/dev/null 2>&1
        echo $! > $fork_pidfile
        exit 0
        ;;
  *)
        action=$2
        do_suspend & >/dev/null 2>&1
        echo $! > $fork_pidfile
        exit 0
        ;;
 esac;

else # We haven't been set up yet, so deal with cmdline args:

 unset action units; seconds=$((0)); lock='unlocked'
 methods=$(cat /sys/power/state)

 [ $# = 0 ] && $0 usage && exit 1

 for param in $*; do
  case $param in
    lock|*-l) lock='lock' ;;
 standby|*-s) [ ! "$action" -a "$(echo $methods | grep -o standby)" ] && action='standby' || usage error ;;
    mem|*-m) [ ! "$action" -a "$(echo $methods | grep -o mem)" ] && action='mem' || usage error ;;
    disk|*-d) [ ! "$action" -a "$(echo $methods | grep -o disk)" ] && action='disk' || usage error ;;
  status|'?') get_jobs
          printf "\nRunning s2 process: $( [ "$running_jobs" ] && printf "($fpid) $running_jobs" || printf "None." )\n"
          exit 0 ;;
  cancel|*-x)
        logging stop; get_jobs
        if [ "$fpid" ]; then
        bloody_die=$(ps ax | grep $(pgrep -P $fpid) | gawk '{/^.[:digit:]+[ ]$/;print $1}')
        kill $fpid 2>/dev/null &
        wait
        kill $bloody_die 2>/dev/null &
        wait
        rm -f $fork_pidfile $log_pidfile
        fi;
        printf "\nAny pending s2 has been canceled.\n"
        exit 0
        ;;
 inmins=*) [ ! "$units" ] && units='mins' || usage error
        seconds=$(($(echo $param | gawk -F= '{/^inmins=[:digit:]+$/;print $2}')*60)) ;;
 insecs=*) [ ! "$units" ] && units='secs' || usage error
        seconds=$((echo $param | gawk -F= '{/^insecs=[:digit:]+$/;print $2}')) ;;
inhours=*) [ ! "$units" ] && units='hrs' || usage error
        seconds=$(($(echo $param | gawk -F= '{/^inhours=[:digit:]+$/;print $2}')*3600)) ;;
  time=*)
        [ ! "$units" ] && units='time' || usage error
        timegiven="$(echo $param | gawk -F= '{/^time=[:digit:][:digit:][:digit:][:digit:]$/;print $2}')"
        [ ! "$timegiven" ] && usage error
        unixtimethen=$(($(date -d "$timegiven" +%s)))
        [ $unixtimethen -lt $(($(date +%s))) ] && unixtimethen=$((unixtimethen+86400))
        seconds=$((unixtimethen-$(date +%s)))
        ;;
  *help*|*-h|-h*|h*) usage ;;
        *) usage error ;;
  esac;
 done;

 get_jobs

 if [ "$running_jobs" ]; then
  printf "\nThere's already a suspend2 instance running. Cancel that one first.\n" && exit 1
 fi;
 if [ "$action" ]; then
  $0 fork $action $seconds $lock
  $0 status
  exit 0
 else
  usage error
 fi;
fi;

# EOF

name it as sleep for example, and call it as sleep mem, mem is a possible parameter

greatings


All times are GMT -5. The time now is 12:34 AM.