Ubuntu: How you do you create a bash script that will run automatically when Unity startups as a user instead of root?



Question:

I have a shell script that is being run automatically under ~/.config/autostart/mining.desktop

I have it setup so that the script runs after Unity is loaded.

It seems to work at startup but if i close the bash window, the process continues to run in the bg as root. How do I setup my desktop file so that the mining script closes as soon as I close the bash window?

My desktop file is:

[Desktop Entry]     Exec=gnome-terminal --command "/user/local/claymore/mine.sh"      Hidden=false     NoDisplay=false     X-GNOME-Autostart-enabled=true   

"Top" reports the ethdcrimer is running as user root.


Solution:1

To make this happen use the cron tool to create a cron job for particular user:

  1. Run:

    crontab -u <useranme> -e   
  2. Then add this line or similar based on your code:

    @reboot /user/local/claymore/mine.sh > /dev/null 2>&1  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »