Suppose, the user does
su, switching to
$ su Password: bash-4.2# crontab -l
How can I logout all such users from
root at a certain time?
What I tried
I know, that using this command:
bash-4.2# ps -A -u root | grep bash 2303 tty1 00:00:00 bash 2548 pts/0 00:00:00 bash 3040 pts/0 00:00:00 bash 3080 pts/2 00:00:00 bash
we can get all the Bash shells, owned by
root. But how can I select the one that was generated by
su? When I ran
echo $$ in the su-ed shell, it gives this:
bash-4.2# echo $$ 3040
Then I tried:
bash-4.2# kill 3040
But it didn't kill the
root shell. Plus if I create a
cron job echo $$ it won't give the necessary PID. So, this won't work.
Now I'm stuck.