How to add delete/add user from a shell script

I am trying to get cron job to delete a user.

I can do it easily from the CLI … but not from my cron script.

CLI: (Both these work)

/usr/share/openhab/runtime/bin/client -p habopen users remove myUser
/usr/bin/openhab-cli console -p habopen users remove myUser

Here is (an extract) from my cron script:


# Set environment
. /etc/profile.d/

# Delete user
OUT=$(/usr/share/openhab/runtime/bin/client -p habopen users remove myUser)
echo $OUT >> /root/mylog.txt

If I run this script manually from the debian command prompt (logged in as root):

  • Works perfectly

But when cron runs the script

  • it fails, and /root/mylog.txt contains this: Closed

Any advice on how to get openhab-cli console to work from a script file?


Instead of

/usr/share/openhab/runtime/bin/client -p habopen users remove myUser


echo users remove myUser | /usr/share/openhab/runtime/bin/client -p habopen


Thank you. This worked perfectly,


1 Like