1

Perhaps this is more of a general question on scripting and terminal use than of the use of the `at' command. Regardless, I am exploring the use of the at command to get a handle on its behavior and how I can control it before I use it for a serious script.

I wrote a trivial script named at-test.sh, saved it to $HOME and made it executable:

#!/bin/sh
echo $(date +%H:%M:%s) > /dev/pts/9
exit 0

then ran it via

at -f './at-test.sh' now + 1 minutes

It runs as expected, but I must Ctrl+C to get the shell prompt back. I later learned that the Enter key would work also to get the prompt back. Is there anyway to get the prompt back via a command in the script?

  • That's odd. at should immediately go to the background. What version of at is this (at -V)? What operating system? If Enter works, what else do you need? – terdon Mar 9 at 0:51
  • @terdon - at version 3.1.14 running on LinuxMint 17. I just read this [link] (unix.stackexchange.com/a/4230/340857) which is exactly what is happening. I guess it is of no consequence really, I just thought it was odd behavior. My ultimate plan is to use it to end public computer sessions by timing out, then forcing logoff, so that behavior is probably ok. – cdaaawg Mar 9 at 1:19
2

You've successfully submitted the at job and it has successfully printed the date to (your) terminal at /dev/pts/9. You also have a shell there that has printed a prompt and is duly waiting for your input.

This is a simulation of what happened:

your-prompt-here$ at -f './at-test.sh' now + 1 minutes
job 1 at Fri Mar  8 20:13:00 2019
your-prompt-here$ 

... one minute passes; resume the demonstration

your-prompt-here$ 20:14:1552093897
echo I am still here
I am still here
your-prompt-here$

As you can see, my shell accepted the echo command; my cursor simply wasn't where I "expected" it to be because the at job scribbled onto my terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.