Create a systemd timer for claiming rewards twice a day

Do you want to claim rewards for a steem account automatically twice a day? When:

  • you use a linux system with python and systemctl
  • have beem installed
  • a wallet created (beempy createwallet --wipe)
  • and a posting key stored (beempy addkey)
    then you can follow this tutorial to add a systemd timer for claiming rewards.

Warning

Installing a timer for claiming rewards twice a day is convenient, but involves some risks. We are storing the posting key of an account on a (remote) server. Everyone that manages it to log in as root on the server will be able to receive the posting key. (The wallet password is stored in the script. After copying the wallet-sql library, the attacker can decrypt the stored posting key with the wallet password.)

Never store an owner key or a master key in a beem wallet!

Knowing this, it is advised to immediately change the posting key, when something unusual happens.

At first we need three files:

  • steem-claimreward.timer

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [Unit]
    Description=Claim rewards twice daily

    [Timer]
    OnCalendar=*-*-* 00,12:00:00
    RandomizedDelaySec=43200
    Persistent=true

    [Install]
    WantedBy=timers.target
    `
  • steem-claimreward.service

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [Unit]
    Description=Claim reward service
    After=syslog.target

    [Service]
    Type=oneshot
    User=root
    Group=root
    ExecStart=/root/claimreward.sh
    SyslogIdentifier=steem-claimreward
    StandardOutput=syslog
    StandardError=syslog
  • claimreward.sh

    1
    2
    3
    4
    #!/bin/bash
    beempy updatenodes
    export UNLOCK='Your-Wallet-Password'
    beempy claimreward yoursteemacc

We store steem-claimreward.timer and steem-claimreward.service in /etc/systemd/system.

1
cp steem-claimreward.*  /etc/systemd/system

The bash script is moved to /root. In order to increase security, we assure that only root can read this file:

1
chmod 700 /root/claimreward.sh

It is also possible to replace the root user by another user in the steem-claimreward.service. The claimreward.sh has than to moved to a place the user can access.

Now, replace yoursteemacc with the account name from which you want to claim (posting key of this account has to be stored into the beempy wallet). Then you have to replace Your-Wallet-Password with your beempy wallet password.

Activate the timer

1
systemctl reenable --now steem-claimreward.timer

activates the timer. With

1
systemctl list-timers

or

1
systemctl status steem-claimreward.timer

you can check for the next execution time point.

image.png

The log file can be viewed by:

1
journalctl -f -u  steem-claimreward

Controlling the timer

  • enable

    1
    systemctl enable steem-claimreward.timer
  • disable

    1
    systemctl disable steem-claimreward.timer
  • start

    1
    systemctl start steem-claimreward.timer
  • stop

    1
    systemctl stop steem-claimreward.timer

  1. How to install and use beempy using anaconda
  2. How to write a post with image using beem
  3. Access steemit conveyor for reading account information with beempy