I am having great difficulty in understanding what shows up on ps command. To test my understanding I created below dummy script
#!/bin/bash
for i in {1..100000}
do
date -u
date -u
date -u
done
while running this script I opened a new terminal and executed repeatedly
ps -eaf | grep date | grep -v grep
and I was able to date process in the output.
I later changed dummy script by replacing date -u
with echo "what is going on"
#!/bin/bash
for i in {1..100000}
do
echo "What is going on"
echo "What is going on"
echo "What is going on"
done
while running the updated dummy script, I opened a new terminal and executed repeatedly
ps -eaf | grep echo | grep -v grep
and echo was never shown in output. Why is this? I suspect the reason is the script being a bash script, may be it is using builtin echo therefore it was not displayed in ps output. Am I correct? What am I missing here?
echo
isn't a process. It's a shell built-in command. – Barrowbash
is the world's only shell. It is built intobash
,zsh
and a bunch of others. It is decidedly not built-in tosh
, the Bourne shell. And there is indeed a/bin/echo
executable in coreutils. – Hereinafterecho
. – Laminousps
is absolutely the wrong tool for the job (seeflock
). – Laminous/bin/bash
to/bin/sh
. – Hereinafterbash
isn't the world's only shell. But the OP indicatedbash
in their tags, so I just naturally assumed that's what they are using. – Barrowcurl
was secure, frankly, that would have been a more sensible question. Easier to answer in a cross-platform manner, too. – Laminous