question

rainerb avatar image
rainerb asked

Help with cronjob on VenusGX

Hello,

Sorry for the long post, I hope someone with programming experience can give me a little tip how to solve my problem.

After each VenusGX software update, I always have huge troubles to get my bash-script started again periodically by a cronjob.


Usually I do the following:

  1. I duplicate my bash-script (maxinverterpwr) from a backup on /data to /etc.
    The script itself starts with:

    #!/bin/bash
    set -e

    #---Deactivate Fronius Standby Mode (switch off relais) ---
    dbus -y com.victronenergy.system /Relay/1/State SetValue 0

    ....
    ....
    ....
  2. I make the script executable with chmod +x /etc/maxinverterpwr
  3. With WinSCP I give the script all root rights too (0777)
  4. If I start my script manually in PuTTY with ./maxinverterpwr, it runs without any errors.
  5. Cronjob stuff:
  6. With nano setpowerlevels I create a new file in /etc/cron.d with the following content:
    */10 * * * * root /etc/maxinverterpwr
  7. With crontab setpowerlevels I "convert" it into crontab.
  8. After that, crontab -e shows the following (looks ok for me):
    Is it necessary to delete the setpowerlevels source file or not (I tried both)?
  9. I reboot the VenusGX device.
  10. I would expect that my script will be started every 10 minutes, but it does not!


I am quite desperate because sometimes I get it working after updates (honestly I don't know why it works) but this time I failed. Wheather it is working or not, in the end everything looks the same for me. Any ideas what else I can try? There must be only a tiny thing that I do not consider.


Thank you and best regards,

Rainer

Venus OSVenus GX - VGX
1560579938756.png (20.4 KiB)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
mvader (Victron Energy) avatar image
mvader (Victron Energy) answered ·

Hi @RainerB, /etc, in which the cron resides, is part of the rootfs, which is completely replaced during an update: so when the new file boots, there is no crontab anymore.


The only place that survives an update is /data.


See here for tips on how to do what you want:

https://www.victronenergy.com/live/ccgx:root_access


2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

rainerb avatar image rainerb commented ·

Hi mvader,

thank you for your reply, but my problem ist not that I have to install my script and the crontab after a sw-update.

My problem is that the cronjob does not work after I have configured it (correctly?).


Regards

Rainer


0 Likes 0 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ rainerb commented ·

Ah ok. Then.. better someone else helps you; its outside of what I know by heart.

0 Likes 0 ·
klaus-deiss avatar image
klaus-deiss answered ·

Years later I found this question regarding cron jobs running on venus.

In my opinion the syntax is wrong.

Try:

crontab -e

Then

# m h  dom mon dow   command
30 10 * * * /data/opt/get-solarwetter
* * * * * /data/opt/test-cron

You can control this with

tail -f /data/log/messages

You should have output like this (here for the second command):

root@raspberrypi2:/data/opt# tail -f /data/log/messages
Jun 21 18:32:01 raspberrypi2 cron.info CROND[555]: (root) CMD (/data/opt/test-cron)
Jun 21 18:32:27 raspberrypi2 blabla

greetz

Klaus

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jeroen avatar image jeroen ♦ commented ·
right, if we are going to restore an old thread, have a look at 'export EDITOR' as well ;)
0 Likes 0 ·
klaus-deiss avatar image klaus-deiss jeroen ♦ commented ·
sorry, I dont get u?
0 Likes 0 ·