Shell Command


#Front Cam
  front_preset_1: '/home/hass/shell_scripts/'
  front_preset_2: '/home/hass/shell_scripts/'
  front_preset_3: '/home/hass/shell_scripts/'
  ir_off: '/home/hass/shell_scripts/'

#Rear Cam
  rear_preset_1: '/home/hass/shell_scripts/'
  rear_preset_2: '/home/hass/shell_scripts/'
  rear_preset_3: '/home/hass/shell_scripts/'
  rear_preset_4: '/home/hass/shell_scripts/'

I’'m having all kinds of trouble trying to run a shell command. So far everything I have tried has resulted in failure!

Hmm same as mine except that I’ve tried with none like yours, bash and sudo bash at the front :stuck_out_tongue:

BTW I looked at who owns the file …
ls -l b*.sh
-rwxr-xr-x 1 homeassistant homeassistant 647 Feb 28 22:16

Hmm I had a thought does it matter who owns the directory I’m writing to?

I don’t think so. But hass owns my shell_script dir so you’re the same as me.

I think the problem is the usb thumb drive I’m trying to copy to, it’s that, that refuses permission to mv/cp the back.tgz file, however I don’t know how to solve that problem as it’s a windows formatted drive with only root privileges.

Shell Scripts:


BACKUP_FILE=/media/pi/HASSUSB/hass-config_$(date +"%Y%m%d_%H%M%S").zip

pushd /home/homeassistant/.homeassistant >/dev/null
zip -9 -q -r $BACKUP_FILE . -x"components/*" -x"deps/*" -x"home-assistant.db" -x"home-assistant_v2.db" -x"home-assistant.log"
popd >/dev/null

echo Backup complete: $BACKUP_FILE

Shell Commands:

backup_config: /home/homeassistant/.homeassistant/shell_scripts/


- alias: Backup config
  hide_entity: True
    platform: time
    after: '03:00:00'
    service: shell_command.backup_config

That works for me perfect writes a backup everday at 3 AM.

Make sure you :

sudo chown homeassistant:homeassistant /media/pi/HASSUSB
sudo chmod 777 /media/pi/

Let me know.

Finally it works :smiley: It seems the shell command does not like the single quotes for .sh files, who knew! Many thanks for the help guys.

1 Like

what path do I use if I am using Home Assistant in Synology Docker?