CronTab MetaHub

edited June 8 in Hardware

Hello i want to create a Crontab to execute a script every 5 minutes.

    #!/bin/bash
    cd /home/pi/Apps/MetaBase-Node/
    echo "Try to download Log"
    npm start -- --config /home/pi/Apps/MetaBase-Node/metabase-config.json --command download
    echo ""
    echo "Start logging"
    npm start -- --config /home/pi/Apps/MetaBase-Node/metabase-config.json --command log

I got the following error.

pi@raspberrypi:~/Apps/MetaBase-Node $ sudo ./DownloadandLog.sh                                                                                                          Try to download Log

> metabase-hub@1.2.0 start /home/pi/Apps/MetaBase-Node
> electron . "--config" "/home/pi/Apps/MetaBase-Node/metabase-config.json" "--co                                                                                        mmand" "download"


(electron:1627): Gtk-WARNING **: 13:18:50.353: cannot open display:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! metabase-hub@1.2.0 start: `electron . "--config" "/home/pi/Apps/MetaBas                                                                                        e-Node/metabase-config.json" "--command" "download"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the metabase-hub@1.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log                                                                                        ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-07T20_18_50_394Z-debug.log

Start logging

> metabase-hub@1.2.0 start /home/pi/Apps/MetaBase-Node
> electron . "--config" "/home/pi/Apps/MetaBase-Node/metabase-config.json" "--co                                                                                        mmand" "log"


(electron:1649): Gtk-WARNING **: 13:18:51.639: cannot open display:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! metabase-hub@1.2.0 start: `electron . "--config" "/home/pi/Apps/MetaBas                                                                                        e-Node/metabase-config.json" "--command" "log"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the metabase-hub@1.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log                                                                                        ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-07T20_18_51_678Z-debug.log

Has somebody any ideas?

Thank you very much.

Comments

  • -bash: cd: Apps/MetaBase-Node/: No such file or directory

  • Hello Laura, this was only a copy and paste Error. I update the first post. Sorry for it.

    When i start the script on the local maschine in the graphical user interface it works very well. But in the crontab an with ssh it doesnt works. For me it looks like the script needs the windowmanager of linux?
    Do you have any ideas?

    Thank you very much.

  • Not enough information to comment at this time.

  • Hello Laura, the pi is still in the default setting that i loaded down from the mbientlab Homepage. The only Thing that i have done sudo apt Update and Upgrade thats it. Later on i created the Script. Which Information did you need to got an better overview?

    Thank you very much in advance.

    Best regards

    Andreas

  • edited June 8

    I have 0 information to comment on this. What script? Which metabase? our image? pi4? is the executable working? Does it work without your script? What are you trying to do??????
    I will close this thread if not proper info is provided.

  • edited June 9
    • This is the Script #!/bin/bash cd /home/pi/Apps/MetaBase-Node/ echo "Try to download Log" npm start -- --config /home/pi/Apps/MetaBase-Node/metabase-config.json --command download echo "" echo "Start logging" npm start -- --config /home/pi/Apps/MetaBase-Node/metabase-config.json --command log

    • metabase is the mmr

    • image is your new for rasp 4 and i use a brandnew rasp 4 4gb
    • i want to set the metabase in log Mode and download every 5 minutes the values in a logfile if the download is finished i will set the metabase again to log
    • the executable (metabase) on the desktop is working
    • the script is also working but only from commandline not from cron

    I hope this infos are more helpfully. Thanks for Support.

  • Has somebody else still used crontab for collecting data? ?

  • @Laura do you have any idea whats happen?

  • edited June 11

    Well this is a thread for metawear and not generic coding. As you pointed out, it's running just fine from the command line or the icon so it's not really a metawear related issue.

    This means that your crontab is wrong.

    Probably the cron is not executed by sudo so that could be something to look into.

    Also keep it simple and just see if you can use a cron to do a single thing. Don't make it complicated and debug one small thing at a time. Just see if you can start logging only and remove complexity. Make sure the syntax is right.

Sign In or Register to comment.