unable to force log rotation manually through the network
I currently have a network of 70 clients that we run simulation software on. It appear that when we have the simulation running the log do fill up and sometime when they rotate during the simulation this causes the file either not to rotate, which lock up the client, or does rotate but does not create a new current message file.
I have written a script one of my firsts as a newbie to manually force the rotation. It however does not appear to work as I cannot access the file according to the output.
Here is the script.
/bin/sh!
export SSHPASS="";
#
ssh-keygen && for host in $(cat hosts.txt)
do
sshpass -e ssh-copy-id -o StrictHostKeyChecking=no $host
done;
#
for host in $(cat hosts.txt);
do ssh "$host" ifconfig | grep -A 30 eth0 >> /home/user/Desktop/logrotate/output.$host;
chmod 644 $host/etc/logrotate.conf;
logrotate -f -v $host/etc/logrotate.conf 2>&1 | tee /home/user/Desktop/logrotate/output.$host;
echo $host;
done;
echo "Logs cleaned up.";
exit;
I am new to scripting if any one has any ideas i would appreciate the help.
Sincerely,
Jon.
Responses
Hi Jon,
There is no necessity to specifying host name again in subsequent lines, so remove $host from chmod and next lines and then run the script and check if that works.
Otherwise, you could put all the command in one file and pass it to ssh. Something like this... cat commands.txt | ssh -t <UserName@RemoteHostIP> ... this is also a good option.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
