How to see if script is running?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

How to see if script is running?

Post by Evelen »

Hi, just got my MiLights up, and wanted to try this script: http://www.domoticz.com/forum/viewtopic.php?f=23&t=3402

So i saved the script in home/flemmingss/domoticz/script/wake_me_up_light.sh on the server (ubuntu server).
Also installed Netcat

Than I made a dummy switsh named "start wake_me_up_light.sh" with on-action:
script://home/flemmingss/domoticz/scripts/wake_me_up_light.sh

but nothing happening if i start it.
How can I see if scripts is running?
(So i can see if the problem is the script, og if it is that the script is not started).

Never started scripts before, just used blockly.
Logg:

Code: Select all

2016-02-05 22:40:45.277 User: flemmingss initiated a switch command
2016-02-05 22:40:45.277 (Dummy) Lighting 2 (start wake_me_up_light.sh)
Image
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to see if script is running?

Post by Egregius »

You could add a echo line to the script.

replace

Code: Select all

function verzend(){
  echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT
  sleep $RUNTIME
}
with

Code: Select all

function verzend(){
  echo -n -e $SENDCOM | nc -u -q 1 $IP $PORT
  echo $(date +"%Y-%m-%d %H:%M:%S") : $SENDCOM >> /var/log/script.log
  sleep $RUNTIME
}
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: How to see if script is running?

Post by Evelen »

same result.
also no script.log in var/log/ :(
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to see if script is running?

Post by Egregius »

I now see that you only have 2 // instead of 3

2 // = relative to domoticz scripts folders
3 /// = absolute path

script://home/flemmingss/domoticz/scripts/wake_me_up_light.sh
script:///home/flemmingss/domoticz/scripts/wake_me_up_light.sh

Also, I believe it should be in the domoticz logfile. Something like executing script /home/flemmingss/domoticz/scripts/wake_me_up_light.sh

Is the script executable for the user domoticz runs?
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: How to see if script is running?

Post by Evelen »

Now I got this:

Code: Select all

2016-02-05 23:56:56.125 User: flemmingss initiated a switch command
2016-02-05 23:56:56.125 (Dummy) Lighting 2 (start wake_me_up_light.sh)
2016-02-05 23:56:56.360 Executing script: /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
2016-02-05 23:56:56.362 Error: Error executing script command (/home/flemmingss/domoticz/scripts/wake_me_up_light.sh). returned: 32256
"Is the script executable for the user domoticz runs?"
I don't know, how do i check?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to see if script is running?

Post by Egregius »

ls -l /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
should have x in the output:
-rwxr--r-- 1 pi pi 464 Jan 17 22:51 wake_me_up_light.sh

x = executable
if not:
chmod +x wake_me_up_light.sh

https://www.google.be/?gws_rd=ssl#q=mak ... able+linux
oliviers
Posts: 74
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: How to see if script is running?

Post by oliviers »

This looks like a long-running script. Domoticz doesn't like that. Scripts should be as quick as possible.
The way to go: Write two scripts:
The first one, which you will assign to "action on", will execute quickly (as to avoid disturbing Domoticz), and will just launch the second script, in background, with all your other commands, delays, etc:

The (very simple) first script will look like:

Code: Select all

#!/bin/bash
/home/pi/domotics/scripts/wake_me_up_light.sh &  <== Please note the "&" (ampersand) which will ensure that 'wake_me_up_light.sh ' is launched in background, thus allowing this script to proceed and complete without waiting
Hope this helps,
Oliviers
Paris area
Raspberry Pi 4 - RFXComm 433 - IrTrans - Zwave
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: How to see if script is running?

Post by Evelen »

Egregius wrote:ls -l /home/flemmingss/domoticz/scripts/wake_me_up_light.sh
should have x in the output:
-rwxr--r-- 1 pi pi 464 Jan 17 22:51 wake_me_up_light.sh

x = executable
if not:
chmod +x wake_me_up_light.sh

https://www.google.be/?gws_rd=ssl#q=mak ... able+linux
Image

oliviers : Is this a script O make to start the orginal script?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How to see if script is running?

Post by Egregius »

the script isn't executable. Run this command:
chmod +x /home/flemmingss/domoticz/scripts/wake_me_up_light.sh

But, as Oliviers said, place another script in between.
Something like /home/flemmings/domoticz/scripts/wake_me_up_light_exe.sh
with this content:

Code: Select all

#!/bin/bash
/home/pi/domotics/scripts/wake_me_up_light.sh &
Then put script:///home/flemmings/domoticz/scripts/wake_me_up_light_exe.sh in the action of the switch.
With this script in between, domoticz can continue instantly because the _exe script starts the real script in the background.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest