Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Input:inject' of type 'Repeat - at a specific time' not working #16

Closed
rajr0 opened this issue Oct 26, 2016 · 22 comments
Closed

'Input:inject' of type 'Repeat - at a specific time' not working #16

rajr0 opened this issue Oct 26, 2016 · 22 comments
Assignees

Comments

@rajr0
Copy link

rajr0 commented Oct 26, 2016

I think, in order for 'Input:inject' of type 'Repeat - at a specific time' (Time-of-Day) to work, 'cron' needed to be installed inside the docker.
I had to add in the Dockerfile the following line
'RUN apt-get install -y cron'

I'm using the Node-RED container to control many switches at specific times; for eg:- turn on/off FishTank light.

$ docker run -it --rm hypriot/rpi-node:4 bash
root@44b3c8a909c0:/# cron
bash: cron: command not found
root@44b3c8a909c0:/#

@knolleary
Copy link
Member

The inject node does not use the external cron command. Does the 'inject at specific time' option not work for you then? What have you tried?

@vielmetti
Copy link
Contributor

Note that Docker on some systems is prone to clock drift. Two instances of people seeing this:

machyve/xhyve#46
https://forums.docker.com/t/time-in-container-is-out-of-sync/16566

@jthomas
Copy link
Collaborator

jthomas commented Nov 17, 2016

Hello @rajr0,

Are you still having issues with this? If so, can you help us by answering Nick's questions.

@albertskog
Copy link

albertskog commented Nov 21, 2016

Hi! I have the same issue with repeat at a specific time not working on my Raspberry Pi (not running the Docker image)!
Edit: Running Node-Red v0.15.2, npm 2.15.11, node v6.9.1 and latest Raspbian (4.4.26-v7+)

@jthomas
Copy link
Collaborator

jthomas commented Nov 21, 2016

@albertskog does it run at all or just at a later or earlier time?

@albertskog
Copy link

albertskog commented Nov 21, 2016

From what I can tell so far it never runs automatically, just when I press the button on the node. I also tried setting it up to run every minute, it also does nothing..

@techr
Copy link

techr commented Nov 23, 2017

Just having inject node and inject at specific time does not generate any injection : (crontab setting seems to be correct)
[
{
"id": "4a97f20f.161c6c",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "a4f30c22.14802",
"type": "inject",
"z": "4a97f20f.161c6c",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "55 22 * * *",
"once": false,
"x": 110,
"y": 60,
"wires": [
[
"8ac23610.84b048"
]
]
},
{
"id": "8ac23610.84b048",
"type": "debug",
"z": "4a97f20f.161c6c",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 307.16668701171875,
"y": 62,
"wires": []
}
]

@dceejay
Copy link
Member

dceejay commented Dec 15, 2017

does the docker container even have a cron process daemon ?

@knolleary
Copy link
Member

@dceejay I refer you to my previous comment - the Inject node doesn't have any dependency on the cron system command.

@dceejay
Copy link
Member

dceejay commented Dec 15, 2017

ah yes - though the node-cron issue list does have some interesting issues that may be relevant
https://github.com/kelektiv/node-cron/issues

@NodeGuy
Copy link

NodeGuy commented May 20, 2018

I had this problem too. I fixed it by changing the timezone on my host and then rebooting.

@evertos
Copy link

evertos commented Sep 4, 2018

@NodeGuy, Thank you for the info got exactly the same problem. NodeRed showed me the correct time but the system time was not correct.

Ubuntu/Debian Distros
To change the timezone:

sudo dpkg-reconfigure tzdata

And reboot.

@RaymondMouthaan
Copy link
Contributor

Node-RED 1.0.0 is now available on docker hub - https://hub.docker.com/r/nodered/node-red.

This closes this issue.

There are a few changes to the new release, please read the README for further details.

@ryanrdetzel
Copy link

Are we sure this is closed with 1.0? I'm having issues with inject in the official 1.0 docker.

@RaymondMouthaan
Copy link
Contributor

@ryanrdetzel, can you provide the flow (json) so I can test it?

@ryanrdetzel
Copy link

ryanrdetzel commented Oct 2, 2019

I don't even see node-cron in the node_modules.

bash-4.4$ ls node_modules/no
node-pre-gyp/       node-red/           node-red-node-rbe/  node-red-node-tail/ nopt/
bash-4.4$ ls node_modules/no

Simple inject with a time and then a debug node

[{"id":"3de6a7eb.61d858","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"2188d43b.089d6c","type":"inject","z":"3de6a7eb.61d858","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"24 07 * * *","once":false,"onceDelay":0.1,"x":510,"y":325,"wires":[["b925c66a.8ada48"]]},{"id":"b925c66a.8ada48","type":"debug","z":"3de6a7eb.61d858","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":325,"wires":[]}]

@dceejay
Copy link
Member

dceejay commented Oct 2, 2019

the node-cron package is in the core of node-red so will have been minified by the build step. It installs as node_modules/cron

@RaymondMouthaan
Copy link
Contributor

RaymondMouthaan commented Oct 2, 2019

I just tested your flow and it works as expected.

The steps I took:

  1. Create a new test container with timezone set to Europe/Amsterdam:
docker run -it -e TZ=Europe/Amsterdam -p 1880:1880 nodered/node-red:latest
  1. Imported the flow you supplied.

  2. Modified the time at in the inject node to trigger it soon.

Screen Shot 2019-10-02 at 13 35 33

note clicking in the debug node on the timestamp changes the way the time shows.

@ryanrdetzel
Copy link

Thanks, I tried that command and it did work so I pulled down the images again and it seems to be fixed. Not sure what happened as I was on 1.0.0 and I'm still on 1.0.0 now but it's working. 🤷‍♂

@RaymondMouthaan
Copy link
Contributor

RaymondMouthaan commented Oct 2, 2019

Thanks, I tried that command and it did work so I pulled down the images again and it seems to be fixed. Not sure what happened as I was on 1.0.0 and I'm still on 1.0.0 now but it's working. 🤷‍♂

Glad i could help :-)

Version of NR did not change, the code of NR did not change only a permission issues was solved.

Did you use -e TZ=<your_timezone> in your previous command?

@dceejay
Copy link
Member

dceejay commented Oct 2, 2019

@pm-mic
Copy link

pm-mic commented Nov 22, 2020

I just ran into this issue and needed somewhat more time to get it fixed, and barely anywhere a working answer was provided. Someone mentioned somewhere that you either need to set the variable TZ or you need to link the timezone folders, but not both. In no way could I get the TZ variable to work, but the folder linking did it. For anyone else running into this issue, here is my docker-compose for running mosquitto and node-red with the proper timezone on raspbian buster:

version: "3"
services:
broker:
container_name: mosquitto
image: eclipse-mosquitto
volumes:
- "./mosquitto:/mosquitto"
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
networks:
- localnet
ports:
- "1883:1883"
- "9001:9001"
restart: unless-stopped
node-red:
container_name: node-red
depends_on:
- broker
image: nodered/node-red
volumes:
- "./node-red:/data"
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
user: "0"
networks:
- localnet
ports:
- "1880:1880"
restart: unless-stopped
networks:
localnet:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests