Remote Script command logging question

I've noticed that when running a script that connects to a number of our servers (to essentially run batch commands) that the commands aren't logged in the user's .sh_history or .bash_history files. Is there a place where this is logged (assuming the script itself isn't doing the logging and I'm not tee'ing the output anywhere)?

I'm talking specifically about AIX, but I would assume this question applies to all the *nix flavors.

As a tag-along to this post, I often nohup these commands (like sendmail -bi) so the script can run through all the hosts quickly. What can I enter in the script to create one large nohup.out on the machine running the script that's reaching out to all the others?Right now I've got

for node in `cat /home/root/script/shortlist`
#for node in `cat /usr/local/bin/AIX_server_list`
do
echo $node
ssh $node lssrc -s sendmail
echo "***"
ssh $node cp /etc/aliases /etc/aliases.old
scp -p /etc/aliases $node:/etc/aliases
ssh $node nohup sendmail -bi &
ssh $node lssrc -s sendmail
ssh $node cat /home/root/nohup.out >> ~/script/sendmailbi_log.txt
echo "%%%%%%%%%%%%%%%%%%%%%%%%"
done

but that failed miserably, I'm guessing that's because the nohup was given via an ssh and not in an interactive shell so nothing got logged?

In short, no. If you use ssh to connect, you can probably put something in the stored public key on the target (~/.ssh/authorized_keys)

Are you connecting as root or a general user?

Robin
Liverpool/Blackburn
UK

See also useless use of backticks. If the list of hosts grows too large your code will malfunction, but this code never will:

while read node
do
...
done < hostlist

Note you may want to < /dev/null for ssh, so that it doesn't eat lines from stdin inside the loop.

Thanks for the input. I'm doing this all as root.

As for the second part of my post, I ended up putting most of the script in one file that's now being called by a much shorter script that will tee the output to a log file. Its not elegant, but it does what I need it to as far as the logging goes.
Thanks Corona, looks like I've got some more reading to do :slight_smile:

Much appreciated!