Tag Info

Hot answers tagged

22

You are searching for at (at@wikipedia)? usr@srv % at now + 15 min at> YOUR COMMAND HERE You can define multiple commands that should be executed in 15 min, seperate them with a return. Confirm all commands with control+d.


12

Sleep can fail if it is terminated during execution: $ sleep 2 $ echo "$?" 0 $ sleep 2 ^C $ echo "$?" 130 Since sleep is an external executable, it is also conceivable that the fork or exec calls could fail, which would also cause bash to generate an error code >0.


12

Use cron (or anacron). Cron is designed for running things at intervals. That is the only thing it does, and there has been a lot of work put into cron for many years to make it what it is today. The chances that you're going to write a better scheduler in your script are effectively nil. Using cron will work better, avoid having unnecessary code in your ...


11

I have had luck using PowerNap (it is packaged for ubuntu-sever, but the source is there so you should be able to compile it on anything) to suspend backup machines when they aren't doing anything. However, this won't wake them up automatically. There is also a PowerWake program bundled with the PowerNap source tarball (packaged as powerwake in Ubuntu) ...


10

#!/bin/sh for page in {1..50} do wget -q -U Mozilla "http://admin.domain.com/products_search/?p=$page" -O - \ | tr '"' '\n' | grep "^Product photo for " | cut -d ' ' -f 3 > bproduct.txt sleep 10 done Should work


7

sleep on Linux accepts seconds too (at least all the versions I've ever seen); can't you just use sleep 600 on both?


6

The fade out is probably the screensaver kicking in. Try to disable it by going to System->Preferences->Look and Feel->Screensaver and disabling "Activate screensaver when computer is idle" if indeed the active screen saver is "Blank screen". The fact that the fading out can't be interrupted is a bug it seems. E.g. Fedora has a bugreport stating it is a ...


6

OS X can do this now, as of Snow Leopard. It's made possible through the Sleep Proxy Service. It's pretty much automatic. The only requirement is that you have a second always-on Apple device on your LAN that can act as the sleep proxy. Their current low-power embedded boxes all support this, I believe: Airport, Time Machine, and Apple TV. In the ...


5

In newer versions of bash (at least v2), builtins may be loaded (via enable -f filename commandname) at runtime. A number of such loadable builtins is also distributed with the bash sources, and sleep is among them. Availability may differ from OS to OS (and even machine to machine), of course. For example, on openSUSE, these builtins are distributed via the ...


5

Assuming it is a shell script, this should work: while [ $(date +%H:%M) != "04:00" ]; do sleep 1; done That's for 24 hour times. If you want this to continue both at 4:00 AM and 4:00 PM, use this instead: while [ $(date +%I:%M) != "04:00" ]; do sleep 1; done


5

Use cron because it is a better and more standard practice. At least if this is something that will regularly run (not just something you patched together in a minute). cron is a cleaner and more standard way. It's also better because it runs the shell detached from a terminal - no problem with accidental termination and dependencies on other processes. ...


4

See time(7), and the manpages it references. An excerpt: High-Resolution Timers Before Linux 2.6.21, the accuracy of timer and sleep system calls (see below) was also limited by the size of the jiffy. Since Linux 2.6.21, Linux supports high-resolution timers (HRTs), optionally configurable via CONFIG_HIGH_RES_TIMERS. On a system that ...


4

Unless you're running a realtime kernel, I wouldn't use sleep times < 10ms anyway tbh. Even if the scheduler is willing to pre-empt another process for your timeout, jitter will probably dominate your actual sleep times. Summary: avoid such small intervals unless you have a realtime kernel. If you can't change kernel, your best bet may be to pin your ...


4

xset --help usage: xset [-display host:dpy] option ... To control Energy Star (DPMS) features: -dpms Energy Star features off +dpms Energy Star features on dpms [standby [suspend [off]]] force standby force suspend force off force on (also implicitly enables DPMS features) ...


4

As root user, and since Fedora 20 uses systemd the more appropiated way to do this is through the hibernate target: systemctl hibernate If you want to do this as normal user, you could use sudo and add the following line on /etc/sudoers through the visudo command: user hostname =NOPASSWD: /usr/bin/systemctl hibernate Other solution to allow hibernate ...


3

You should assume that any command can fail for various reasons even if having sleep fail is indeed very unlikely. ( sleep 10 ; echo "hello world" ) & means background sleep and execute echo after sleeping process but if sleep fails echo will run anyway see complete explanation sleep 10 && echo "hello world" & means you need to wait ...


3

Creating a lot of subprocesses is a bad thing in an inner loop. Creating one sleep process per second is peanuts. There's nothing wrong with while ! test_condition; do sleep 1 done If you really want to avoid the external process, you don't need to keep the fifo open. my_tmpdir=$(mktemp -d) trap 'rm -rf "$my_tmpdir"' 0 mkfifo "$my_tmpdir/f" while ! ...


3

Also can check RF kill switches, try "rfkill list all", and if thats interesting persue further.


3

It would be easier to simply launch the program directly and have it run the update immediately (or it could sleep for some small delay if you really needed it to). If this is in a script itself (eg, bash), simply call the update script directly (likely redirecting the output): update-my-thingy < /dev/null > /dev/null 2>&1 If it's in a ...


3

I use a short script I keep in my path, called after, containing at now + "$@" This way it's very easy to, for example, type: after 15 min then any commands and Ctrl-D, or echo COMMANDS | after 15 min which does the same.


3

Check your paths! A common mistake when creating cron jobs is assuming that the path is the same when the cron runs as when the user runs the file. mysqldump, and expect might need to be given full paths, instead of relative ones.


2

You may need to change some things like the grep criteria and the CPU threshold but here it goes: #!/bin/bash cd $RUN_DIR nohup ./CloudServer >& /dev/null & PID=`ps aux |grep $RUN_DIR/CloudServer|grep -v grep| head -n 1 |awk '{print $2}'` while [ `top -n 1 -b -p $PID | grep $PID |awk '{print $9"/1"}' |bc` -gt 1 ] do sleep 2 echo ...


2

Fork a script that waits for a few seconds. { sleep 5; update-my-program; } & If your goal is to do the upgrade as soon as your program exits, but no sooner, arrange for your program to terminate by calling execve instead of exit. The execve system call replaces the current program by another. In C, there are several variants (execl, execp, etc.) ...


2

I faced this issue long time back, when i had linux mint. It was very irritating . A lot of R&D led me to ubuntu forums , where i got the solution . Note that this is not my work, i am just saving you the trouble of digging through that forum . 1) Start a text editor with elevated priveleges. For example, enter at the command prompt: gksudo gedit ...


2

Debugging this type of issue can be tricky. I would first start with trying to manually force it into suspend mode with the following command: PM_DEBUG=true pm-suspend Then check /var/log/pm-suspend.log for hints on what might be going wrong. Perhaps something is going wrong during suspend mode. Here's a good article on the Ubuntu wiki on how to debug ...


2

I think the following should work: ip link set wlan0 up. Of course I'm not sure your wifi interface is wlan0, but you can check it by running: iw dev, and if it's like wlan1, just replace wlan0 with it.


2

Does cron use some kind of triggers or something making it efficient over the other? I have taken a look at cat /proc/`pidof crond`/stack. Having printed it for a few consecutive times I see that crond just sleeps in hrtimer_nanosleep. >cat /proc/`pidof crond`/stack [<ffffffff810a0614>] hrtimer_nanosleep+0xc4/0x180 [<ffffffff810a073e>] ...


2

There are already some good answers on cron and sleep performance, but I want to add some kind of feature comparison. Pro cron: running already on Unix/Linux systems stable and proven designed for background processes runs from system start-up onward, and so will your script, once installed easier entry of long-term cycles (hours, days, weeks) allows ...


2

This is from the ps manpage: PROCESS STATE CODES: Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process: D uninterruptible sleep (usually IO) R running or runnable (on run queue) S interruptible sleep (waiting for an event to ...


1

This sounds like a process that either has or is having it's nice level set to a lower level. I'd confirm this with the command: $ ps -eo "%p %y %x %c %n" | less The last column is the nice value and should be 0 in most cases. If it's some other value between -20 (most favorable scheduling) to 19 (least) then something is setting the nice value to this ...



Only top voted, non community-wiki answers of a minimum length are eligible