How to script at job creation?
Bo Berglund
bo.berglund at gmail.com
Fri Dec 11 07:12:54 UTC 2020
On Thu, 10 Dec 2020 14:05:01 +0100, Bo Berglund
<bo.berglund at gmail.com> wrote:
>I found a way to get rid of the user interaction when creating an at
>job as follows (all on one line):
>
>echo "timeout --signal=2 65m getstream input18.mp4" | at 23:58
>tomorrow
>
>When executed on the command line it creates the at job without any
>interaction at all, which was my first hurdle.
>
>I will test putting a few of these commands into a script, which I can
>then run daily to create the at jobs.
I must be missing something important because I cannot get this to
work from within a script...
This is what I have now and it just refuses to *run* the echo command
inside the terminal.
#!/bin/bash
NEXTDAY=`date --date="tomorrow" +%Y-%m-%d`
CMDTIM1="echo \"timeout --signal=2 65m getmsnbcstream ${NEXTDAY}_"
#Now create the at jobs
CMDAT="${CMDTIM1}inp19.mp4\" | at 00:58 tomorrow"
$CMDAT
exit
What happens when I run this from the command line is:
$ ./makeatjobs
"timeout --signal=2 65m getmsnbcstream 2020-12-12_inp19.mp4" | at
00:58 tomorrow
I.e. it just *displays* the command I want to execute with echo and
pipe into at after removing "echo"...
So why is echo removed from the command (seems like the script
*executes* echo internally rather than sending it to the command
line)?
In other scripts I have written this does not happen, there the
command string gets executed as expected with the same basic script
structure. But then I don't use echo...
So is there a special handling involved when one wants to use echo to
pipe a string over into another command?
Notice that the echo command itself disappears and the only thing
happening is that what follows echo is displayed on the terminal.
How does one execute the echo command itself including the pipe to the
second process?
I need the script to do the following, which works if I type it into
the command window manually:
echo "timeout --signal=2 65m getmsnbcstream 2020-12-12_inp19.mp4" | at
00:58 tomorrow
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list