I am trying to auto-archive multiple logs file in a different directory. I've succeeded to archive every file but every time I executed the script it gives me a message like this:
./mainlog.sh: line 17: /opt/cafex/FAS-2.5.21/domain/log/alert.log: Permission denied
Here's some information about the script itself:
- The script is located in (/root/) and already have (chmod +x permission)
- The line that's giving me the message is this:
domain_log= $(sudo tar -cPzvf domain_log_$DATE.tar.gz /opt/cafex/FAS-2.5.21/domain/log/* --transform='s:/opt/cafex/FAS-2.5.21/domain/log/::g')
I tried to do this:
domain_log= $(sudo tar -C /opt/cafex/FAS-2.5.21/domain -cPzvf domain_log_$DATE.tar.gz /opt/cafex/FAS-2.5.21/domain/log/*)
But the result remains the same (permission denied)
Does anyone have similar experience like me?