当我插入USB设备时,我正在尝试运行rsync。它以我想要的方式运行,但是我很确定它运行了两次,但我不确定为什么。当我在那里使用脚本杀死并重新启动其中一个程序时,它将执行两次操作……这就是问题的根源。我想知道我的服务设置方式是否也导致它在umount
上运行?
Udev规则:
ACTION=="add", KERNEL=="sd?1", ENV{SYSTEMD_WANTS}="sty_usbSync.service"
sty_usbSync.service:
[Unit]
Description=Syncing thumdrive with PI
Requires=media/usb0.mount
After=media/usb0.mount
[Service]
Type=oneshot
ExecStart=/opt/styles2304/sty_usbSync.sh
[Install]
WantedBy=media/usb0.mount
sty_usbSync.sh:
#!/bin/bash
#echo "STY: shutting down emulationstation..."
#killall emulationstation
echo "STY: syncing..."
rsync -rP /media/usb0/rsync/ /
echo "STY: unmounting..."
umount /dev/sdb1
#echo "STY: restarting emulationstation..."
#emulationstation
最后是systemctl status
服务的sty_usbSync
:
Dec 09 22:43:22 retropie systemd[1]: Starting Syncing thumdrive with PI...
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: STY: syncing...
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: sending incremental file list
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: home/pi/RetroPie/roms/neogeo/test.txt
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: [110B blob data]
Dec 09 22:43:22 retropie sty_usbSync.sh[12868]: STY: unmounting...
Dec 09 22:43:22 retropie systemd[1]: Started Syncing thumdrive with PI.