Handling the timing is the script's responsibility. Even if that means using /bin/sleep today, it might not in the future, so killing that isn't actually guaranteed to work long-term. Well, I guess you can make that guarantee, but it's neater not to. My point is you shouldn't kill the sleep directly from outside the script, since the sleep is an ...
In another terminal,
Kill the sleep process:
pkill -f "sleep 5m"
The loop will go on.
If pkill is not available in your OS, you can get the PID using:
$ ps aux | grep '[s]leep'
username 14628 0.0 0.0 8816 672 pts/19 S+ 08:33 0:00 sleep 5m
Then run kill PID to kill the process (here: kill 14628).
This is good for manually killing ...
I like @sitaram's method of using ionotifywait. However, a similar thing can be done using more ubiquitous infra - the shell read command (which can take an optional timeout in Bash/ksh/Zsh) and a FIFO.
The wait-loop looks something like this:
while true; do
read -t $((5*60)) <> /tmp/myfifo
echo "Executed every ...
The term for this is CPU affinity. You can use the taskset command to set it for individual processes.
To run <command> on the first 6 cores (cores #0-#5) only:
taskset -c 0-5 <command> [arguments for command]
If the process is already running, you can set its affinity by PID instead:
taskset -c 0-5 -p <PID of an existing process>
If you ...
If you have inotifywait available, you could setup a sentinel file (an empty file, with some unique name), and use inotifywait.
I.e., replace the sleep with this:
inotifywait -t 300 $HOME/.cache/sentinel
When you want to trigger this to execute "part X" right away, just touch $HOME/.cache/sentinel from some other ...
Something (or more than one thing) seems to have run that program twice.
try ps ax -o ppid,pid,lstart,cmd to get start time of processes. And search scripts that may have started it.
Also look at parent-process-id.
I think the easiest way would be to have the script check for the presence of a certain file.
Then, in the while statement, sleep many times in shorter intervals. If you use seconds as your short interval, you would use a for loop that runs 300 times (=5 minutes).
for x=1 to 300
sleep 1 second
From outside, you ...
It's a bit late, but it could be helpful for others.
What I did:
cat /proc/PID/stack to get some direction. In my case it was connected with inode and filesystem:
[<ffffffff83bcf12f>] truncate_inode_pages_final+0x4f/0x60 ...
Releasing pages is possible in principle and in practice.
malloc and free don’t necessarily result in reserved address space; they can be implemented using mmap and munmap, in which case the corresponding address space and any populated pages can both be returned to the kernel after munmap. It’s also possible for processes to reduce their allocated address ...
$! contains the pid of the right most command in the last pipeline run asynchronously. Here, you'd just need to run exec twice:
exec > >(tee -a mylog)
exec 2> >(tee -a mylog >&2)
But maybe you don't need to record those pids. Those tee processes will exit (upon see eof) when your script (and all the processes it ...
Yes, on RedHat systems, typically a person uses numactl
While it cannot guarantee a process binds to a specific CPU (as it will permit binding to another CPU should the desired CPU be unavailable, it will configure the job launch to make the best effort to bind and (if the process sleeps) rebind to the desired CPUs.
Note that in this case, CPU means "...
You need to monitor stdout, e.g. using grep, so, I don't know, maybe
while true; do
echo $! > $PIDFILE
# echo "Program restarted at $( date )" >> /var/log/program.log
) | while read X; do
if (echo "$X" | grep "search" >...
In the end, it is up to the operating system kernel if it allows "giving back" (virtual memory) pages piecemeal (it might be a mess to do so; and not that relevant in practice, a page that isn't used will soon enough get evicted from RAM anyway). For more or less the same reasons, the language's runtime may just keep stuff around (if you e.g. in C ...
CROND is a child process of crond; it gets created when a crontab entry is processed.
$ ps -ef | grep -i cron
UID PID PPID C STIME TTY TIME CMD
root 2289 1 0 Feb12 ? 00:00:02 /usr/sbin/crond -n
root 446475 2289 0 14:37 ? 00:00:00 /usr/sbin/CROND -n
Process # 2289 (crond) is the parent process for ...
As non-root, I shouldn't be able to get a faster priority. So, indeed a positive number is slower, negative faster:
$ renice -n -10 6341
renice: failed to set priority for 6341 (process ID): Permission denied
$ renice -n +10 6341
6341 (process ID) old priority 0, new priority 10
$ renice -n 0 6341
renice: failed to set priority for 6341 (process ID): ...
Previous answers are excellent, pointing out that threads are processes inside the Linux kernel and that you can clone( ) any subset of the process state you like anyway.
But I think it's helpful to remember that it matters how much context can be shared or must be saved uniquely, and how many cycles it may take for a context switch, which may depend on how ...