I have this installer shell script in a bash script.
- I am doing a rename of the existing text file (backing it up).
- I remove old file
Copy fresh file to the target dir
mv /target/data.ini /target/data_$(date +"%Y%m%d_%H%M%S").ini rm -f /target/data.ini cp /install/data.ini /target/data.ini
For some reason the cp command does not always copy the file.
Is it possible that previous mv or rm operation was not completed?
I am unable to see any error since its running as part of the script; if I execute the commands manually it's working fine.
/target
an automounted filesystem?logger
command is very useful to send script output (including errors) to the system log or journal. Capturing the error messages would make it much easier to debug the issue. I would suggest getting the error message logged or emailed as much easier than taking random guesses at what might be going wrong.sleep 2 ;
beforecp
command. It may slow down but can increase precision.