Bash Pagina 106: Diferență între versiuni
Sari la navigare
Sari la căutare
Admin (discuție | contribuții) |
Admin (discuție | contribuții) |
||
Linia 4: | Linia 4: | ||
#set trap on EXIT for service | #set trap on EXIT for service | ||
trap "systemctl start smb.service" EXIT | trap "systemctl start smb.service" EXIT | ||
#stop service | #stop service | ||
systemctl stop smb.service | systemctl stop smb.service | ||
#do the backup | #do the backup | ||
tar czf windows_share.tgz /srv/WindowsTeam | tar czf windows_share.tgz /srv/WindowsTeam | ||
#no need to restart here the service | #no need to restart here the service | ||
#the trap will catch any exit, even successfull | #the trap will catch any exit, even successfull |
Versiunea curentă din 31 octombrie 2024 07:49
Folosirea trap în asigurarea continuității rulării serviciului
#!/bin/bash #set trap on EXIT for service trap "systemctl start smb.service" EXIT #stop service systemctl stop smb.service #do the backup tar czf windows_share.tgz /srv/WindowsTeam #no need to restart here the service #the trap will catch any exit, even successfull