Ok, it looks like I spoke (well, wrote
technically) too soon!

Invoking:
- Code: Select all
kill -SIGKILL $$
inside a script only terminates execution of that script. It will not log out the user from the virtual console. From what I can surmise, in order to end a login session from within a virtual terminal, the process that was invoked upon login has to be the one terminated (the parent shell). By running a script (and thereby creating another instance of the shell), the PID returned by the $$ variable inside that script is not the same one as that of the parent shell, which I'm trying to terminate in the first place. A quick (and dirty) way to achieve this is the method I originally posted earlier. It does have the unwanted side-effect, although I can live with that. As I said previously, my users don't have a need to invoke a terminal session, so, the unwanted side-effect is pretty much a non-issue.
Using $$ in lieu of `basename $SHELL` will work
if I source the script at the shell prompt, e.g.:
- Code: Select all
$ . new-time.sh 60
instead of invoking it as a separate process, like so:
- Code: Select all
$ ./new-time.sh 60