OMV\ExecException: Failed to execute command with exit code 2

    • OMV 3.x
    • Resolved
    • OMV\ExecException: Failed to execute command with exit code 2

      Hi Guys,

      I have some trouble executing the following command as planned task:

      Source Code

      1. read -r -d $'\0' line < <(find/srv/dev-disk-by-label-Data-RAID/@data/.@snapshots -maxdepth 1 -type d -printf'%T@ %p\0' | sort -z -n) && file="${line#* }" && btrfs subvolume delete $file

      This ugly one-liner should delete the oldest snapshot on my Data-RAID. But when I'am trying to run this task, I get the following error message:

      Source Code

      1. OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C; export SHELL=/bin/sh; sudo --shell --non-interactive --user=root -- read -r -d $'\0' line < <(find /srv/dev-disk-by-label-Data-RAID/@data/.@snapshots -maxdepth 1 -type d -printf '%T@ %p\0' | sort -z -n) && file="${line#* }" && btrfs subvolume delete $file 2>&1' with exit code '2': in /usr/share/openmediavault/engined/rpc/cron.inc:175

      But, I dont't know where the problem is. Maybe you've got an idea :D ?!
    • daniel.971 wrote:

      export SHELL=/bin/sh
      You're using bash syntax in your command while OMV uses sh. I would try to put the whole code in a little script reading

      Shell-Script

      1. #!/bin/bash
      2. read -r -d $'\0' line < <(find/srv/dev-disk-by-label-Data-RAID/@data/.@snapshots -maxdepth 1 -type d -printf'%T@ %p\0' | sort -z -n) && file="${line#* }" && btrfs subvolume delete $file
      and then let the script execute as planned task.