Is there a Linux command that does nothing, but never exits?

If we look at system calls, there's actually one that does exactly that, pause(2):

pause() causes the calling process (or thread) to sleep until a signal is delivered ...

Of course, then we'd just need a program that uses it. Short of compiling the two-liner C program below, the easiest way is probably with Perl:

perl -MPOSIX -e pause

In C:

#include <unistd.h>
int main(void) { return pause(); }

Just add a sleep command.

while true; do sleep 600; done

will sleep for 10 minutes between loops.


Since you've mentioned ctrl-C I assume that you want to use it in interactive terminal. So you may just wait for input.

$ read

or just use arbitrary other commands which read from stdin like cat. They do "nothing" as long as there is no input.

$ cat >/dev/null

or even better without using stdin:

$ tail -f <<EOF
EOF

Tags:

Command Line