The following block executes fine in script but gives exit code 1. But when i run this at shell prompt executes fine with message
tar: Removing leading `/' from member names
and gives exit code 0. Why it is behaving differently. How to fix this to avoid exit code 1 when run using script.
tar -czf $tracedir/dbtrace.tar.gz $tracedir
status=$?
if [ $status -ne 0 ]; then
echo "The error code is---"$status >> output.log
fi
How to avoid exit code 1 when run using script ?
1
fromtar
(GNU tar 1.29) is special. It means "some files were changed while being archived"; it may also come from a subprocess (e.g.gzip
). Did you receive any error message? What was it? Side note: quote the variables. – Kamil Maciorowski May 30 '19 at 06:37