2

Hello and thank you for being so helpful. I am trying to run a script at startup that reduces the power limits of my gpus. The shell command is in init.d and I have tried using symlink to rc1 and rc3. The shell command has also been made executable using Chmod +x. I am running Ubuntu 16.04 as well. When I restart the computer only 1 card drops the wattage to the appropriate level while the other two stay unchanged. This is gpu0. Any help would be much appreciated. I have also tried using Crontab and have had difficulties. My script is as follows:

#!/bin/bash

echo "Run as sudo to lower power-limits."
echo ""

nvidia-smi -i 0 -pl 100
nvidia-smi -i 1 -pl 100
nvidia-smi -i 2 -pl 100

echo ""
echo ""

nvidia-smi
  • 1
    You need the full path of the command when in crontab; that is a regular one here. As for boot time, Ubuntu 16.04 uses not UpStart but systemd. – Rui F Ribeiro Feb 3 '18 at 15:54
  • I’ve used the full path in crontab. I did notice some cron folders under /etc/ must they be there? I was using @reboot /Desktop/reduce-power-limit.sh/ – Tyler S Feb 3 '18 at 16:00
  • I have also tried placing the shell command in cron.d and get the same issue – Tyler S Feb 3 '18 at 16:01
  • Put a call to your script in /etc/rc.local and use the full path to commands. Also, does it work if you run it manually after boot & login ? – ivanivan Feb 3 '18 at 17:14
  • Have you tried starting the script from the console? Bash isn't installed by default on Ubuntu, the shebang should be #!/bin/sh. – Murphy Feb 3 '18 at 18:43
1

You could put the full path (where this script is actually located) in rc.local. Whatever you put in rc.local will run like root user while the OS is ready to execute the script (plaese, forgive the lack of exactitude and for my english), so be carefull. I leave you an example:

nano /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/local/samba/bin/samba_dnsupdate --use-samba-tool
exit 0

This means that when my OS is ready to run scripts it will run samba_dnsupdate with the option --use-samba-tool, and this script is actually in /usr/local/samba/sbin/

Greetings

  • I do not have an rc.local folder I have rc1-6.d and rcS.d – Tyler S Feb 3 '18 at 23:02
  • I have found the rc.local file. How would I run the script in this file – Tyler S Feb 4 '18 at 1:13
  • I have added /etc/bin/reduce-power-limit.sh to the rc.local file. Is there anything else I need to do? It’s still not working. – Tyler S Feb 4 '18 at 3:35
  • I put the wrong path in rc.local. It works!!!!! Thank you so so so much – Tyler S Feb 4 '18 at 3:46
  • Sorry for the late answer, I'm in Cuba and I only have internet in my work... so if it work for you then congratulations!!! Any question feel free to ask here :-) – k.Cyborg Feb 5 '18 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.