Re: bash in at command
> Infatti se hai voglia di fare alcune prove ti accorgerai che se scheduli
> ad esempio lo script che ho mandato[¹] da shell at (senza specificare
> l'opzione -f di at per intenderci) non da errori, se lo scheduli con il
> comando -f da errore. In entrambi i casi viene generato il warning
> "commands will be executed using /bin/sh".
Preferisco il caso semplice, non "errore o non errore". Faccio "ps u $$"
per vedere che processo sta girando. Con "at" interattivo parte sh,
che ignora #!/bin/bash come commento:
laptopo% tty
/dev/pts/10
laptopo% at now; sleep 2
warning: commands will be executed using /bin/sh
at> #!/bin/bash
at> ps u $$ > /dev/pts/10
at> <EOT>
job 6 at Tue Oct 4 14:50:00 2022
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
rubini 14462 0.0 0.0 2420 528 ? SN 14:50 0:00 sh
Quindi gira sh. "sleep 2" l'ho messo per non avere il prompt in mezzo.
Con "-f" il risultato e` lo stesso:
laptopo% cat > /tmp/at
#!/bin/bash
ps u $$ > /dev/pts/10
laptopo% at now -f /tmp/at; sleep 2
warning: commands will be executed using /bin/sh
job 7 at Tue Oct 4 14:52:00 2022
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
rubini 14469 0.0 0.0 2420 524 ? SN 14:52 0:00 sh
Gira sh. Il programma, se eseguito, va con bash. Ma "-f" usa un file
invece di leggere da stdin, e quello che legge lo manda a sh.
laptopo% chmod +x /tmp/at
laptopo% /tmp/at
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
rubini 14475 0.0 0.0 3756 2804 pts/10 S+ 14:54 0:00 /bin/bash /tmp/
laptopo% at now; sleep 2
warning: commands will be executed using /bin/sh
at> /tmp/at
at> <EOT>
job 8 at Tue Oct 4 14:54:00 2022
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
rubini 14481 0.0 0.0 3836 2932 ? SN 14:54 0:00 /bin/bash /tmp/
man bash:
[...] For both at and batch, commands are read from standard input or the
file specified with the -f option and executed. [...]
-f file Reads the job from file rather than standard input.
Ma non parliamo troppo di questi strumenti, che poi ci si accorge che
esistono e vengono rotti. Come fgrep: sara` rimosso da una prossima
versione di grep, perche` "grep -F" fa la stessa cosa. Cosi` un tot
di vecchi script si romperanno, per risparmiare un inode e 28 byte in
sistemi peni di gigabyte dimm
Reply to: