Sponsored Content
Top Forums Shell Programming and Scripting expert , alternative for sleep not use memory Post 302562768 by pooyair on Saturday 8th of October 2011 07:06:04 AM
Old 10-08-2011
expert , alternative for sleep not use memory

Code:
while sleep 1; do
pgrep Polo || {
                  kill `pidof Polo` >/dev/null 
    
    /var/bin/polo_start.sh start &
    echo `date` R >> /var/log/Check_Polo .log
    }
done
exit 0

well , i use that script as a watchdog in my box (with has just 32 mb memory) which check every second if Polo binary is not running , it would start it. this works functionally right here.
but the problem is , it always use memory for sleep 1 command (since my box has a few memory and this watchdog is always running so it's really important for me to save memory of them ) as in top command always shows:
Code:
Command                                %MEM  
sleep 1                                4.7% 
[pgrep]                                 5 %

i need expert advice , how to change or improvw my script (esp those command) to would not use memory for sleep 1, ... or on the other words use least memory resources. would really appreciate any helps.

P.s : Linux 2.6.23.17_stm23_A21 #1 PREEMPT sh4 GNU/Linux
and pgrep , ... comes from busybox.
Best Regards.

Last edited by pooyair; 10-08-2011 at 08:23 AM..
 

6 More Discussions You Might Find Interesting

1. Solaris

expert vi commands

:) Hi UNIX friends, Where do I get advanced vi commands to practice. Please Help Me. Love (4 Replies)
Discussion started by: Love
4 Replies

2. UNIX for Advanced & Expert Users

Expert Opinion

This perhaps does not belong in ths category; apologies, however, we have a heated debate going and your input will decide the result. Should UNIX (HP, AIX, etc) be rebooted following a monthly cycle (Every month, or a qtr, etc.). We have some UX admins (grumps) who say they have seen a UX... (6 Replies)
Discussion started by: rsheikh
6 Replies

3. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

4. Shell Programming and Scripting

Expert cp command

How can I use the cp command to copy every file that I can find inside several folders cp -R *test* folder Supose there is ./122342343teste122343.txt ./bound/123teste1223453.txt ./feed/123teste1223453.txt and i want the files 122342343teste122343.txt, bound/123teste1223453.txt... (12 Replies)
Discussion started by: lipe.82
12 Replies

5. Solaris

Becoming a Solaris expert?

Hello everyone, how do you really study to become an expert in solaris OS? Thanks (3 Replies)
Discussion started by: cjashu
3 Replies

6. Shell Programming and Scripting

Alternative to Sleep?

Greetings. I've been wondering about this one for some time: Is there an alternative to sleep in bash? The reason: I'd like to simply limit the amount of processor usage in continuous while : script scenarios without spawning endless sleep processes as well. After beating the manpages, I... (14 Replies)
Discussion started by: LinQ
14 Replies
ACPILID(4)						   BSD Kernel Interfaces Manual 						ACPILID(4)

NAME
acpilid -- ACPI Lid Switch SYNOPSIS
acpilid* at acpi? DESCRIPTION
The acpilid driver supports ACPI ``lid switches''. The powerd(8) daemon can be used to control actions against the events of opening or closing the lid. The script used is /etc/powerd/scripts/lid_switch, and the events are either pressed (the lid was closed) or released (the lid was opened). EXAMPLES
The following example modifies the mentioned script in order to put the system into (S3) sleep when the lid is closed: ... case "${2}" in pressed) logger -p info "${0}: suspending..." # As in sleep_button, kill some daemons. # /etc/rc.d/dhcpcd stop /etc/rc.d/network stop /etc/rc.d/wpa_supplicant stop # Suspend. # if /sbin/sysctl hw.acpi.sleep.state >/dev/null 2>&1; then /sbin/sysctl -w hw.acpi.sleep.state=3 fi # Waking up. # /etc/rc.d/wpa_supplicant start /etc/rc.d/network start /etc/rc.d/dhcpcd start ... SEE ALSO
acpi(4), powerd(8), sysmon_pswitch(9) HISTORY
The acpilid driver appeared in NetBSD 1.6. BSD
January 9, 2011 BSD
All times are GMT -4. The time now is 01:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy