More
referral
Increase your income with Hive. Invite your friends and earn real cryptocurrency!

How to run a command with the boot

Hi, i have a rig of 6 Vega 64 and I would like to run this command automatically when I turn on the system: amdmemtweak --CL 16 --RAS 30 --RCDRD 12 --RCDWR 5 --RC 44 --RP 10 --RRDS 3 --RRDL 5 --RTP 5 --FAW 20 --CWL 7 --WTRS 4 --WTRL 9 --WR 16 --WRRD 1 --RDWR 19 --REF 17550 --MRD 8 --MOD 15 --PD 8 --CKSRE 10 --CKSRX 10 --RFC 300
I found something about rc.local but I’m not able to find it.

add to /home/user/xinit.user.sh

working only with Enabled GUI

you can change first line do #!/bin/bash

Thanks for the answer, I tried in every way that I found on internet but I don’t really know how to edit the file. Can you explain how I can do it?

you must log in to the console - be it via ssh or hiveshell, then enter the appropriate commands in the pico editor.

You can also try by running the command from web:

echo "" >> /home/user/xinit.user.sh; echo "amdmemtweak --CL 16 --RAS 30 --RCDRD 12 --RCDWR 5 --RC 44 --RP 10 --RRDS 3 --RRDL 5 --RTP 5 - FAW 20 --CWL 7 --WTRS 4 --WTRL 9 --WR 16 --WRRD 1 --RDWR 19 --REF 17550 --MRD 8 --MOD 15 --PD 8 --CKSRE 10 --CKSRX 10 --RFC 300 ">> /home/user/xinit.user.sh

Hi there.
I added a command to lock gpu clocks in /home/user/xinit.user.sh but it doesn’t seem to execute.
Not sure I understand what you mean by “you can change first line do #!/bin/bash”
Do I need to uncomment that line?
Thank you

xinit.user.sh run when you enable X

#!/bin/bash

this is first line od file. “#” its ok here

  1. How do I enable X then?
    From hiveOS UI I have gui enabled but not sure it does the trick
  2. Could it be that it exexutes but it gets overrided by the OC settings that apply shortly after?. In which case how do I insert a wait period?
  3. I cannot see the console output to see if it actually gets executed as it boots straight into the miner.

Thanks again

ad 1. GUI on boot → Enabled GUI
ad 2.

sleep 10

sleep for 10s

ad 3. because hiveos currently starts motd watch automatically

It seems that that no matter what I do with the sleep interval, the command is not executed.
What could be the reason?
GUI is enabled
i tried
sleep 10 (or 20, 30, 40)
nvidia-smi -i 0,1,2,3,4,5,6 -lgc 1100,1200
But it doesn’t take effect.
It works when I manually run the command

Thank you

1 Like

Just following up.
I can’t seem to get the command to execute on boot irrespective of the sleep interval.
Any other way to script this?
Thank you

Sorry for digging this up but I will do so because I face the same issue and I want to refer to this post for effect (to show that other run to that issue as well)

So I try to run myself a script as well I did

sudo nano /home/user/initx.user.sh 

Inside of which it looks like that:

#!/usr/bin/env bash

# This script is run in terminal after X server start

# uncomment the following line if you want to see miner log after start
#tail -f /run/hive/miner.1
sleep 10
cd /home/user/
./amdtimings.sh

But it doesnt work…

There is a “amdtimings.sh” script on /home/user/ (I can check that by dir /home/user/ and it appears)

And when I try to manually run ./amdtimings.sh on the console or by running a command online via the hiveOS worker control panel the script does what it should (enter custom timings using amdmemtweak tool to my GPUs)

but it just doesnt fire up after boot…

Does “sleep 10” mean sleeping for 10 seconds or 10 minutes? because I thought it means 10 seconds (miner starts after 30 seconds of boot)

Sleep is in seconds I think.
It’s annoying that you cannot script easily a simple command given how powerful and configurable HiveOS is.
If I don’t lock the gpu clocks after boot, I get restarts (something to do with one of PSUs not liking the power spikes from GPUs clocking up).

Hello,

Try this:

cd /opt
mkdir script_dedi
cd script_dedi
nano xinit.dedi.sh

Exemple for me:

#!/usr/bin/env bash

nvidia-smi -i 1,2,3,4,5 -lgc 900

press
F3 “for write” or CTRL + S
F2 “for quit” or CTRL + Q

chmod +x xinit.dedi.sh

After add in reboot or boot crontab

nano /hive/etc/crontab.root

and add this:

@reboot sleep 900 && /opt/script_dedi/xinit.dedi.sh

900 in second / 15 min change with your value time

press
F3 “for write” or CTRL + S
F2 “for quit” or CTRL + Q

Test your script:

bash xinit.dedi.sh

sample cron hiveos:

 ROOT CRON
# applied on every startup

PATH="./:/hive/bin:/hive/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

# clear log file to avoid disk usage
*/15 * * * * /hive/bin/miner logtruncateall


# clear logs to freeup space
#0 * * * * (rm /var/log/*.1; rm /var/log/*.2; rm /var/log/*.gz; echo "" > /var/log/kern.log; echo "" > /var/log/syslog) > /tmp/cron.rmlogs.log 2>&1
#rotate every 5 min, kern.log and syslog can grow up to 1.5G each in 15 min
#since we have pci=noaer, maybe 5 min rotate is too much
*/15 * * * * /hive/sbin/logrotate

#clean screen logs
0 * * * * (for fname in `realpath -eq /run/hive/miner.*`; do echo "" > $fname; done)


# update PCI IDs db
30 12 15 * * update-pciids


# update DNS cache, just in case IP changes once in a lifetime
*/30 * * * * cache-hive-ip


#check agent is running...
*/10 * * * * agent-screen dontattach || echo "[`date`] STARTED BY CRON" >> /var/log/hive-agent.log


# systemd-timesyncd check
0 * * * * /hive/sbin/timesync

# boot nvidia OC dedizones
@reboot sleep 900 && /opt/script_dedi/xinit.dedi.sh

stop miner and server/worker and start after 15 minutes (or 900secondes) since starting the server the script starts automatically

I wrote head quickly, if an error despite my proofreading, tell me I will correct it for future readers.

do you know how to run a command like “xrandr -s 1024x768” to change the screen resolution of my rig monitor at the rig boot?

use dummy on motherboard:

https://fr.aliexpress.com/promotion/promotion_dummy-vga-promotion.html

LoL :grin:

My problem is that I have a small raspberry monitor here and want to change the screen resolution during the boot sequence because it’s impossible right now

Hi,

Better place to add command execute at boot is /etc/rc.local. I use this file to set chassis fan speed on boot.

cat /etc/rc.local

[…]
echo 1 > /sys/class/hwmon/hwmon2/pwm1_enable
echo 170 > /sys/class/hwmon/hwmon2/pwm1
exit 0