Help with a simple Cron job to understand the concept

Hi, i need a little help with a very simply job...
I like to move my files from /mnt/mntroot to /mnt/mntnas

  1. I installed node-red cron +
  2. installed dashboard
  3. add a flow to move the files from /mnt/mntroot to /mnt/mntnas

Questions

  1. how do i exec my exec node with the defined cron schedule in the dashboard..
[{"id":"eb2a7f4f.31f93","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"10a77a49.e89d96","type":"ui_text","z":"eb2a7f4f.31f93","group":"255216a.69effea","order":1,"width":"16","height":"2","name":"CRON Description","label":"Expression Description (updates as you type)...","format":"{{msg.payload.result.description}}","layout":"col-center","x":1008,"y":338,"wires":[]},{"id":"9a6d4f78.ef1e8","type":"cronplus","z":"eb2a7f4f.31f93","name":"","outputField":"payload","timeZone":"","options":[],"x":746,"y":339,"wires":[["10a77a49.e89d96"]]},{"id":"8e7ce209.dea81","type":"function","z":"eb2a7f4f.31f93","name":"describe cmd","func":"msg.payload = {\n    \"command\": \"describe\",\n    \"expression\": msg.payload\n}\nreturn msg;","outputs":1,"noerr":0,"x":531,"y":339,"wires":[["9a6d4f78.ef1e8"]]},{"id":"4c9ba22.ab7135c","type":"change","z":"eb2a7f4f.31f93","name":"","rules":[{"t":"set","p":"ui_add_schedule_name","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":593,"y":135,"wires":[[]]},{"id":"7df4b9ef.055478","type":"change","z":"eb2a7f4f.31f93","name":"","rules":[{"t":"set","p":"ui_add_schedule_payload","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":602,"y":200,"wires":[[]]},{"id":"69ffc222.1bfb0c","type":"change","z":"eb2a7f4f.31f93","name":"","rules":[{"t":"set","p":"ui_add_schedule_expression","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":611,"y":264,"wires":[[]]},{"id":"3f1de456.ee0d1c","type":"change","z":"eb2a7f4f.31f93","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.payload","pt":"msg","to":"ui_add_schedule_payload","tot":"flow"},{"t":"set","p":"payload.name","pt":"msg","to":"ui_add_schedule_name","tot":"flow"},{"t":"set","p":"payload.expression","pt":"msg","to":"ui_add_schedule_expression","tot":"flow"},{"t":"set","p":"payload.command","pt":"msg","to":"add","tot":"str"},{"t":"set","p":"payload.type","pt":"msg","to":"str","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":427,"wires":[["cecd9b30.905ed8","4ffa9a62.f96474"]]},{"id":"cecd9b30.905ed8","type":"cronplus","z":"eb2a7f4f.31f93","name":"","outputField":"payload","timeZone":"","options":[],"x":953,"y":564,"wires":[["d8433dda.29058"]]},{"id":"fb8e1814.c0b138","type":"ui_toast","z":"eb2a7f4f.31f93","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":555,"y":650,"wires":[]},{"id":"d8433dda.29058","type":"switch","z":"eb2a7f4f.31f93","name":"1=Cron Event   2=List Results ","property":"cronplus.triggerTimestamp","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1203,"y":568,"wires":[["fb8e1814.c0b138"],["c353901f.c5efd"]]},{"id":"d3d9efe0.55de","type":"catch","z":"eb2a7f4f.31f93","name":"","scope":null,"uncaught":false,"x":268,"y":790,"wires":[["ad07e54d.8d5d28","9098df89.f8f49"]]},{"id":"ad07e54d.8d5d28","type":"ui_toast","z":"eb2a7f4f.31f93","position":"top right","displayTime":"3","highlight":"red","outputs":0,"ok":"OK","cancel":"","topic":"Error...","name":"","x":732,"y":815,"wires":[]},{"id":"4ffa9a62.f96474","type":"ui_button","z":"eb2a7f4f.31f93","name":"Refresh","group":"255216a.69effea","order":6,"width":"1","height":"1","passthru":true,"label":"","tooltip":"Get status of jobs","color":"","bgcolor":"","icon":"fa-refresh","payload":"{\"command\":\"list-all\"}","payloadType":"json","topic":"","x":748,"y":426,"wires":[["cecd9b30.905ed8"]]},{"id":"a64c1089.bbf18","type":"ui_text_input","z":"eb2a7f4f.31f93","name":"","label":"Expression","tooltip":"CRON expression or date/csv list of dates","group":"255216a.69effea","order":3,"width":"4","height":"1","passthru":true,"mode":"text","delay":"100","topic":"","x":282,"y":265,"wires":[["8e7ce209.dea81","69ffc222.1bfb0c"]]},{"id":"751a8b39.e3cfb4","type":"ui_text_input","z":"eb2a7f4f.31f93","name":"","label":"Name","tooltip":"Schedule Name","group":"255216a.69effea","order":2,"width":"4","height":"1","passthru":true,"mode":"text","delay":"100","topic":"","x":261,"y":136,"wires":[["4c9ba22.ab7135c"]]},{"id":"5694890c.2e6188","type":"ui_button","z":"eb2a7f4f.31f93","name":"","group":"255216a.69effea","order":5,"width":"3","height":"1","passthru":false,"label":"Add","tooltip":"Add or update named schedule","color":"","bgcolor":"","icon":"send","payload":"","payloadType":"str","topic":"","x":264,"y":430,"wires":[["3f1de456.ee0d1c"]]},{"id":"5b98f4f0.d2352c","type":"ui_text_input","z":"eb2a7f4f.31f93","name":"","label":"Payload","tooltip":"Payload to send when schedule fires","group":"255216a.69effea","order":4,"width":"4","height":"1","passthru":true,"mode":"text","delay":"100","topic":"","x":274,"y":200,"wires":[["7df4b9ef.055478"]]},{"id":"970fa334.70a11","type":"ui_template","z":"eb2a7f4f.31f93","group":"255216a.69effea","name":"","order":7,"width":"16","height":"5","format":"<style type=\"text/css\">\n.t1  {border-collapse:collapse;border-spacing:0;border-color:#ccc;}\n.t1 td{font-family:Arial, sans-serif;font-size:14px;padding:8px 3px;border-style:solid;border-width:0px;overflow:hidden;word-break:normal;border-top-width:1px;border-bottom-width:1px;border-color:#ccc;color:#333;background-color:#fff;}\n.t1 th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#f0f0f0;}\n.t1 .t1-36r9{background-color:#000000;color:#ffffff;text-align:left;vertical-align:top}\n.t1 .t1-x2zo{background-color:#c0c0c0;font-size:small;text-align:left;vertical-align:top}\n.t1 .t1-o73e{background-color:#c0c0c0;font-size:small;text-align:center;vertical-align:top}\n.t1 .t1-5qt9{font-size:small;text-align:left;vertical-align:top}\n.t1 .t1-5qta{font-size:small;text-align:center;vertical-align:middle}\n</style>\n<table class=\"t1\">\n  <tr>\n    <th class=\"t1-36r9\" colspan=\"9\">CRON Schedules</th>\n  </tr>\n  <tr>\n    <td class=\"t1-x2zo\">Name</td>\n    <td class=\"t1-x2zo\">Expression</td>\n    <td class=\"t1-x2zo\">Payload</td>\n    <td class=\"t1-x2zo\">Description</td>\n    <td class=\"t1-x2zo\">Next run</td>\n    <td class=\"t1-x2zo\">State</td>\n    <td class=\"t1-o73e\">Delete</td>\n    <td class=\"t1-o73e\">Pause</td>\n    <td class=\"t1-o73e\">Resume</td>\n  </tr>\n  <tr  ng-repeat=\"item in msg.payload\">\n    <td class=\"t1-5qt9\">{{item.config.name}}</td>\n    <td class=\"t1-5qt9\" style=\"white-space: nowrap\" nowrap>{{item.config.expression}}</td>\n    <td class=\"t1-5qt9\">{{item.config.payload}}</td>\n    <td class=\"t1-5qt9\">{{item.status.description}}</td>\n    <td class=\"t1-5qt9\">{{item.status.nextDescription}}</td>\n    <td class=\"t1-5qta\"><i class=\"fa fa-{{item.status.isRunning ? 'play' : 'pause'}}\"> </i></td>\n\n   <td class=\"t1-5qta\">\n       <md-button class=\"md-raised\"\n        ng-click=\"send([[{payload:{command:'remove', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-trash\"> </i></md-button>\n   </td>\n   <td class=\"t1-5qta\">\n       <md-button class=\"button\" \n       ng-click=\"send([[{payload:{command:'pause', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-pause\"> </i></md-button>\n   </td>\n   <td class=\"t1-5qta\">\n       <md-button class=\"button\" \n       ng-click=\"send([[{payload:{command:'start', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-play\"> </i></md-button>\n   </td>\n\n  </tr>\n\n </tbody>\n</table>\n\n<!--<table id=\"table\" class=\"table table-striped table-responsive-md btn-table\" >-->\n<!--     <tr>-->\n<!--        <th>Name</th> -->\n<!--        <th>Expression</th> -->\n<!--        <th>Payload</th> -->\n<!--        <th>Description</th>-->\n<!--        <th>Next run</th>-->\n<!--        <th>State</th>-->\n<!--        <th>Delete</th>-->\n<!--        <th>Pause</th>-->\n<!--        <th>Resume</th>-->\n<!-- </tr>-->\n<!-- <tbody>-->\n<!-- <tr ng-repeat=\"item in msg.payload\">-->\n<!--   <td >{{item.config.name}}</td>-->\n<!--   <td style=\"white-space: nowrap\" nowrap>{{item.config.expression}}</td>-->\n<!--   <td >{{item.config.payload}}</td>-->\n<!--   <td >{{item.status.description}}</td>-->\n<!--   <td >{{item.status.nextDescription}}</td>-->\n<!--   <td >{{item.status.isRunning ? 'Running' : 'Paused'}}</td>-->\n<!--   <td>-->\n<!--       <md-button class=\"md-raised\"-->\n<!--        ng-click=\"send([[{payload:{command:'remove', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-trash\"> </i></md-button>-->\n<!--   </td>-->\n<!--   <td>-->\n<!--       <md-button class=\"button\" -->\n<!--       ng-click=\"send([[{payload:{command:'pause', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-pause\"> </i></md-button>-->\n<!--   </td>-->\n<!--   <td>-->\n<!--       <md-button class=\"button\" -->\n<!--       ng-click=\"send([[{payload:{command:'start', name: item.config.name}}, {payload:{command:'list-all'}}]]);\"> <i class=\"fa fa-play\"> </i></md-button>-->\n<!--   </td>-->\n<!-- </tr>-->\n<!-- </tbody>-->\n<!--</table>-->\n\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":705,"y":690,"wires":[["f6b0cf4b.00a16"]]},{"id":"c353901f.c5efd","type":"function","z":"eb2a7f4f.31f93","name":"Make table data","func":"if(!msg.payload || !msg.payload.result || !msg.payload.result.length){\n    msg.payload = [];\n    return msg;\n}\n\nmsg.payload = msg.payload.result;\nreturn msg;","outputs":1,"noerr":0,"x":545,"y":690,"wires":[["970fa334.70a11"]]},{"id":"9098df89.f8f49","type":"debug","z":"eb2a7f4f.31f93","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":691,"y":864,"wires":[]},{"id":"f6b0cf4b.00a16","type":"link out","z":"eb2a7f4f.31f93","name":"","links":["b9b9e3e3.d4933"],"x":840,"y":690,"wires":[]},{"id":"ef5b2f12.f6bec","type":"ui_template","z":"eb2a7f4f.31f93","group":"255216a.69effea","name":"CRON Info","order":8,"width":"16","height":"12","format":"<div>\n<pre>CRON Format...\n\n    s  m  h  md m  wd y\n    |  |  |  |  |  |  |\n    *  *  *  *  *  *  *    Field              Allowed values    Special symbols\n    |  |  |  |  |  |  |    -----------------  ---------------   ---------------\n    `--|--|--|--|--|--|->  Second (optional)  0-59              * / , -\n       `--|--|--|--|--|->  Minute             0-59              * / , -\n          `--|--|--|--|->  Hour               0-23              * / , -\n             `--|--|--|->  Day of Month       1-31              * / , - L W\n                `--|--|->  Month              1-12 or JAN-DEC   * / , -\n                   `--|->  Day of Week        0-7 or SUN-SAT    * / , - L #\n                      `->  Year (optional)    1970-2099         * / , -\n                \n</pre>    \n</div>\n\n<style type=\"text/css\">\n.t2  {border-collapse:collapse;border-spacing:0;border-color:#ccc;}\n.t2 td{font-family:Arial, sans-serif;font-size:14px;padding:2px 2px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#fff;}\n.t2 th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ccc;color:#333;background-color:#f0f0f0;}\n.t2 .t2-dg6o{background-color:#000000;color:#ffffff;text-align:left;vertical-align:top}\n.t2 .t2-6e8n{font-weight:bold;background-color:#c0c0c0;border-color:inherit;text-align:left;vertical-align:top}\n.t2 .t2-0pky{border-color:inherit;text-align:left;vertical-align:top}\n</style>\n<table class=\"t2\">\n  <tr>\n    <th class=\"t2-dg6o\" colspan=\"2\">Example CRON Expressions</th>\n  </tr>\n  <tr>\n    <td class=\"t2-6e8n\">Expression</td>\n    <td class=\"t2-6e8n\">Description</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">* * * * * *</td>\n    <td class=\"t2-0pky\">Every Second</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 * * * * *</td>\n    <td class=\"t2-0pky\">Every minute</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 */10 * * * *</td>\n    <td class=\"t2-0pky\">Every 10 minutes</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 */20 1 * * *</td>\n    <td class=\"t2-0pky\">Every 20 minutes, between 01:00 AM and 01:59 AM</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 15,30,45 * * * *</td>\n    <td class=\"t2-0pky\">At 15, 30, and 45 minutes past the hour</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 0 12 * * *</td>\n    <td class=\"t2-0pky\">Every day at noon - 12pm</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 0 2 29 FEB * 2020-2040</td>\n    <td class=\"t2-0pky\">At 02:00 AM, on day 29 of the month, only in February, every 4 years, 2020 through 2040</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 0 7 * *</td>\n    <td class=\"t2-0pky\">MON#1 * At 07:00 AM, on the first Monday of the month</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 0 12 * JAN,FEB,MAR,APR *</td>\n    <td class=\"t2-0pky\">Every day at noon in January, February, March and April</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">* * 1W * *</td>\n    <td class=\"t2-0pky\">Every minute, on the first weekday of the month</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">* * * * Tue#3</td>\n    <td class=\"t2-0pky\">Every minute, on the third Tuesday of the month</td>\n  </tr>\n  <tr>\n    <td class=\"t2-0pky\">0 12 * * MONL</td>\n    <td class=\"t2-0pky\">At 12:00 PM, on the last Monday of the month</td>\n  </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":715,"y":750,"wires":[[]]},{"id":"9747c91d.c10348","type":"link in","z":"eb2a7f4f.31f93","name":"","links":["dde0b2cf.76d48"],"x":562,"y":534,"wires":[["cecd9b30.905ed8"]]},{"id":"b16ca5c8.751da8","type":"comment","z":"eb2a7f4f.31f93","name":"documentatie","info":"https://flows.nodered.org/flow/79a66966a6cc655a827872a4af794b94\nklik t dashboard aan","x":106.5,"y":64,"wires":[]},{"id":"9d399608.e3a128","type":"exec","z":"eb2a7f4f.31f93","command":"sudo mv /mnt/mntroot/*.* /mnt/mntnas/","addpay":false,"append":"","useSpawn":"false","timer":"5","oldrc":false,"name":"copy motionoutput","x":728.5,"y":1005.5,"wires":[["14c033dd.55c37c"],[],[]]},{"id":"60d11749.5c1708","type":"inject","z":"eb2a7f4f.31f93","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270.5,"y":1003,"wires":[["9d399608.e3a128"]]},{"id":"ea0a3041.6c8bc","type":"comment","z":"eb2a7f4f.31f93","name":"How do i connect this exec to my cron job","info":"","x":1015.5,"y":1003,"wires":[]},{"id":"c029f319.15567","type":"comment","z":"eb2a7f4f.31f93","name":"This exec command gives an error","info":"","x":983.5,"y":1048,"wires":[]},{"id":"14c033dd.55c37c","type":"debug","z":"eb2a7f4f.31f93","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","x":898.5,"y":940,"wires":[]},{"id":"255216a.69effea","type":"ui_group","z":"","name":"Default","tab":"368ee3ca.e34a6c","disp":false,"width":"16","collapse":false},{"id":"368ee3ca.e34a6c","type":"ui_tab","z":"","name":"CRON","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

why notuse the watch node to watch the first directory and move the file when one appears there?

I have a nas that sleeps at night and my motion video files gives an error at nightime when writing to the nas...
So wrting to a local folder and move them at certain times is the only way i could thnk of...
moving when something changes still gives the error that my nas isnt available..
when i could do your tricjk after a certain time (after 6.00) it would be great!

So the cron+ node will fire when a timer goes off. you can look at the output to determine if it is the timer you want and tehn connect it to the input of the exec node,

Initially I used a "normal crontab job" to run a script to delete files older than a certain number of days to prevent the storage for my AI system from filling up.

Now I just use an inject node set to "repeat at a certain time" to trigger an exec node that launches the script. Straight forward, and I can test it immediately by triggering the inject node manually.

1 Like

thanks i am almost there! it works!
Only need to grap the error from the OS. command execution

it gives an code 0 or 1 which i want to use. But it is not in the payload, so how do i get this info in my flow and react on this code when it is for example 1

[{"id":"eb2a7f4f.31f93","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"9d399608.e3a128","type":"exec","z":"eb2a7f4f.31f93","command":"sudo mv /mnt/mntroot/*.* /mnt/mntnas","addpay":true,"append":"","useSpawn":"false","timer":"5","oldrc":false,"name":"copy motionoutput","x":545.5,"y":463.5,"wires":[["14c033dd.55c37c"],[],[]]},{"id":"ea0a3041.6c8bc","type":"comment","z":"eb2a7f4f.31f93","name":"How do i connect this exec to my cron job","info":"","x":889.5,"y":1008,"wires":[]},{"id":"14c033dd.55c37c","type":"debug","z":"eb2a7f4f.31f93","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":919.5,"y":452,"wires":[]},{"id":"718066f6.336598","type":"inject","z":"eb2a7f4f.31f93","name":"move files to NAS","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"onceDelay":0.1,"x":284.5,"y":464,"wires":[["9d399608.e3a128"]]}]

Read the node-red help "working with messages".

Its a 5 min read and well worth the time. For example, once you "get it" you won't need to ask questions like this ever again

There is a copy button appears when you hover on the item in debug.

i will do!

1 Like

Ok, tried to read the message and act on it...
does not work, got an error invalid topic specified...

[{"id":"eb2a7f4f.31f93","type":"tab","label":"Move to NAS","disabled":false,"info":""},{"id":"9d399608.e3a128","type":"exec","z":"eb2a7f4f.31f93","command":"sudo mv /mnt/mntroot/*.* /mnt/mntnas","addpay":true,"append":"","useSpawn":"false","timer":"5","oldrc":false,"name":"copy motionoutput","x":545.5,"y":463.5,"wires":[["ca9da11f.fbd25"],[],[]]},{"id":"ea0a3041.6c8bc","type":"comment","z":"eb2a7f4f.31f93","name":"How do i connect this exec to my cron job","info":"","x":889.5,"y":1008,"wires":[]},{"id":"14c033dd.55c37c","type":"debug","z":"eb2a7f4f.31f93","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":906.5,"y":441,"wires":[]},{"id":"718066f6.336598","type":"inject","z":"eb2a7f4f.31f93","name":"move files to NAS","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"onceDelay":0.1,"x":284.5,"y":464,"wires":[["9d399608.e3a128"]]},{"id":"ca9da11f.fbd25","type":"switch","z":"eb2a7f4f.31f93","name":"switch","property":"rc.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":742.5,"y":450,"wires":[["14c033dd.55c37c","b8e7e9a8.835c08"],["14c033dd.55c37c","7d97f9f0.e5d588"]]},{"id":"b8e7e9a8.835c08","type":"function","z":"eb2a7f4f.31f93","name":"lamp aan","func":"msg.payload = {};\nmsg.payload.command = \"switchlight\";\nmsg.payload.idx = 1002;\nmsg.payload.switchcmd = \"On\";\nreturn msg;","outputs":1,"noerr":0,"x":916.5,"y":334,"wires":[["e5bac5f2.5d4258"]]},{"id":"7d97f9f0.e5d588","type":"function","z":"eb2a7f4f.31f93","name":"lamp uit","func":"msg.payload = {};\nmsg.payload.command = \"switchlight\";\nmsg.payload.idx = 1002;\nmsg.payload.switchcmd = \"Off\";\nreturn msg;","outputs":1,"noerr":0,"x":906.5,"y":530,"wires":[["e5bac5f2.5d4258"]]},{"id":"e5bac5f2.5d4258","type":"mqtt out","z":"eb2a7f4f.31f93","name":"","topic":"","qos":"","retain":"","broker":"465cbf12.c733c","x":1122.5,"y":457,"wires":[]},{"id":"465cbf12.c733c","type":"mqtt-broker","z":"","name":"mqttdomoticz","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

it works!

Thank you all....

Only my os command gives an error
Command failed: sudo mv /mnt/mntroot/. /mnt/mntnas/ 1571994398331mv: doel '1571994398331' is geen map

Strange, because when i cut and paste it directly on my os... it works overthere!

sudo mv /mnt/mntroot/. /mnt/mntnas

When you run it in the OS do you need to put in a password? If you do then that is the problem. You can't enter a password through the exec node (it is a system restriction, not a node-red restriction). One solution is to use visudo to say that the node-red user does not need to enter a password to run the command mv, however that is dangerous as then your node-red flow could (accidentally or maliciously) use mv to trash your system. A better way is probably to give the node-red user access to the locations you are writing to, or to change where the files are in the first place. Then you don't need to use sudo.

ok, thats solved to!
Now the last part, where the whole thing was just about..
I need the watch node only be executed if time is between 600 and 2400.
I think i have to use a function (to check the time and create a true or false message and then a switch
that reacts on true or false..
Last part is easy, to write the function not!
I searched for an example on the node-red documentation and forum for a time check function, still did not find it....

What do you want to happen outside this time? Ignore the watch node output or queue the result for action when the time is right?

If you use the most excellent node-red-contrib-cron-plus you can enter what ever times you wish to trigger your flow. No code required.

Bonus point...

As this node is ultra flexible, you could even go as far as making a dashboard to control times and watch progress.

Example ...
https://flows.nodered.org/flow/79a66966a6cc655a827872a4af794b94

ignore the watch output..

i tried myself, but still strugling...

let myHour = $now().hour();
let valid = (myHour >=6 && myHour <=24);
if (valid) return msg;
return null;

I would install the timerange switch node.

The time range switch node looks perfect for your use case, but just for completeness that code should be something like
let myHour = (new Date()).getHours();
which will give you the hours in the range 0 to 23.
https://www.w3schools.com/jsref/jsref_obj_date.asp

ok, it works! THANKS to you all!
Now i going to test/try the timerange node
[
{
"id": "195224b7.dfb92b",
"type": "function",
"z": "eb2a7f4f.31f93",
"name": "check time between 0600 and 2400",
"func": "let myHour = (new Date()).getHours();\nlet valid = (myHour >=6 && myHour <=24);\nif (valid)\n{msg.payload = true}\nelse \n{msg.payload = false}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 356.5,
"y": 329,
"wires": [
[
"f0b4bb9a.a490d8",
"6a5caeae.60ac8"
]
]
}
]

If I was doing this here is how I would code it
flow 1:
inject (running when flow started) -> change node (set flow.movefile to boolean false)

flow 2:
inject (running every ten minutes) -> switch (check if flow.movefile = boolean true) true side -> exec (running your command) -> check for errors and display them if any exist.

flow 3:
cron+ node (with two rulesets - one named 'startmove' at the start time, a second called 'stopmove' at the time to stop moving files => switch node which tests the name of the ruleset.

If name of the ruleset = 'startmove' send to a change node that sets set flow.movefile to boolean true.

If the name of the ruleset = 'stopmove' send to a change node that sets set flow.movefile to boolean false

all done

There a more then one switch time range
How do i know which is the correct?
this? node-red-contrib-time-range-switch