Problem runing smartthings cli commands as cron jobs

i am running Linux KNX 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux
and i have problems running smartthings commands as cron jobs.
Here is how my crontab looks
33 * * * * sudo /usr/bin/smartthings devices:commands XXXXXXXX-XXXXX-79b2-4577-00000XXXXXXXX main:switch:off

I try everything to debug that problem reading logs etc. no output from that job is generated just the command won’t run.
Anyone met this problem ?

I don’t really familiar with crontab, but if you don’t receive logs or something like that maybe the sudo is waiting for the password.

All other cron jobs with sudo works … only smartthings doesn’t work.
If i run directly from the console it works.
If i put smartthings inside bash script all the commands work till the line with smartthings…

Are you sudo’ing to root? If so why? Is the command permitted in the sudoers config file? What does the cron.log file show is happening?

i try both with sudo and without the result is the same only smartthings act like that …

Any suggestion how to debug this problem ?

It’s been a long time since I did this sort of thing. Back then I would have redirected stdout to a private logfile and then redirected stderr to stdout so I got the logging of the CLI where I wanted it, not where cron may or may not have been configured to send it.

I’ve not used the CLI with sudo. Does that not have implications for the configuration or have you already allowed for that?

1 Like

Finally i done the job with expect script in few steps with confirmations and it works