Hello,
I have a problem with the following script. I hope that some can point me in the right direction as I am new to this. This script is intended to log into 69 clients and change the messages log after backing it up and moved to a backup directory. We do have the logs rotating, however we have a simulation lab and sometimes when all the clients are running client does rotate but does not create a log and the system crashes. I wrote this script and can access the clients using auto ssh but once I log in none of the commands are executed. Please note i did not put the passwords in the script.
#!/bin/sh
#
#
#
set -x
for host in $(cat sorted.txt);
do
sshpass -p "" autossh -M0 -t root@$host
echo $host
cd /var/log;
pwd
mv messages "messages.$(date)"
ls -l "messages.$(date)"
pwd
echo $host
touch messages
chmod 600 messages
echo $host;
echo "------------------------------------------------------" >> /home/user/Desktop/logrotate/output.$host
ls -l messages >> /home/user/Desktop/logrotate/output.$host
ls -l 'messages.($date)'
mv "messages.$(date)" >> /home/user/Desktop/logrotate/backup;
done;
#
echo Logs cleaned up;
exit;
Bash script Problem.
General support questions
-
- Posts: 4
- Joined: 2017/11/09 18:55:09
Return to “CentOS 7 - General Support”
Jump to
- CentOS General Purpose
- ↳ CentOS - FAQ & Readme First
- ↳ Announcements
- ↳ CentOS Social
- ↳ User Comments
- ↳ Website Problems
- CentOS 8 / 8-Stream / 9-Stream
- ↳ 8 /8-Stream / 9-Stream - General Support
- ↳ 8 /8-Stream / 9-Stream - Hardware Support
- ↳ 8 /8-Stream / 9-Stream - Networking Support
- ↳ 8 /8-Stream / 9-Stream - Security Support
- CentOS 7
- ↳ CentOS 7 - General Support
- ↳ CentOS 7 - Software Support
- ↳ CentOS 7 - Hardware Support
- ↳ CentOS 7 - Networking Support
- ↳ CentOS 7 - Security Support
- CentOS Legacy Versions
- ↳ CentOS 5
- ↳ CentOS 5 - General Support
- ↳ CentOS 5 - Software Support
- ↳ CentOS 5 - Hardware Support
- ↳ CentOS 5 - Networking Support
- ↳ CentOS 5 - Server Support
- ↳ CentOS 5 - Security Support
- ↳ CentOS 5 - Oracle Installation and Support
- ↳ CentOS 5 - Miscellaneous Questions
- ↳ CentOS 6
- ↳ CentOS 6 - General Support
- ↳ CentOS 6 - Software Support
- ↳ CentOS 6 - Hardware Support
- ↳ CentOS 6 - Networking Support
- ↳ CentOS 6 - Security Support