1

I need to run a 24 by 7 batch program. On power failures I already configured Ubuntu Server 14.04 to power up as soon as energy is back, auto login and start the program.

The process is based on GPU power and get better results with overclock. I was able to do it configuring xorg.conf and executing xinit. When I do that, the screen go white and the command line disapear. I used a remote SSH client to execute "overclock.sh" and start the program and it worked.

My question is that as I won't be able to use the remote client every time, how can I execute others scripts after executing xinit?

CRTL+ALT+F1 return to command line, but how use that on startup script?

I would like to execute on startup: - xinit; - overclock.sh; - start_program.sh;

Update 08/27/2017: Right now, I'm understanding more what is happening:

  1. I'm in the console environment tty1.

  2. When run "xinit" it open a rough screen on tty7.

  3. By pressing CRTL+ALT+F1 I go back to terminal tty1 but is stucked on the "xinit" command. That is why, the .bash-login script don't execute any other command after.

  4. By pressing CTRL+C it stops the tty7 environment and the overclocked don't work.

  5. Now the most strange part: If I press CTRL+Z, I return the control, the overclock works, but when I run the program, only GPU0 start to work.

  6. Also tried "setsid xinit &> /dev/null" and again, everything seens perfect, but only GPU0 work.

7 Another approach: in the rough screen, tty7, I click with the mouse on the upper command line, type overclock.sh and it works. All 8 gpus work nicely. This seems to be more closely to be the answer.

How can I make a batch file to execute commands soon as the tty7 go up?

Update 08/28/2017:

I solved. The magic was study the xterm called from xinit. It receive the parameter -e "command". Put the script as command.

3 Answers3

0

Add the scripts to your crontab using crontab -e:

@reboot /path/to/overclock.sh; /path/to/start_program.sh

If you want to add it to the root crontab (sudo crontab -e), additionally you need to set a user, e. g. root:

@reboot root /path/to/overclock.sh; /path/to/start_program.sh

Read more with man 5 crontab.

dessert
  • 39,982
  • I folowed this article https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up and ended up creating a .conf file on /etc/init. I first tried @reboot /path/to/script but the system just ignore it. I can put xinit on crontab too? – Bruno Carneiro Aug 24 '17 at 07:23
  • You can put xinit in a script, so I don't see why you should not be able to put it in your crontab. I suggest you write a startup script that starts the scripts in your preferred order and add that to your crontab. – dessert Aug 24 '17 at 07:39
  • I will try again to use crontab and back here to report. I was insecure because on the command line, the server don't do nothing after xinit – Bruno Carneiro Aug 24 '17 at 08:03
  • I edited the crontab with -e option, but nothing make the command to be executed. I even used service cron start. So I put the commands on .bash_login file. But when xinit runs, it frozen the screen and don't run the other commands – Bruno Carneiro Aug 26 '17 at 20:25
  • Well did you reboot? Of course cron knows when it's just restarted and doesn't execute the @reboot commands then. – dessert Aug 26 '17 at 20:37
  • Yes, I even shutdown the nobreak because I was testing other stuff. I tried to install again with "sudo apt-get install cron". The Ubuntu I'm using is almost clean, I installed recently. Provably it's missing something else. – Bruno Carneiro Aug 27 '17 at 04:39
0

I can see three ways of doing this :

  • In /etc/init.d : put the scripts you want to launch at startup. The script needs to be structured as other scripts of the directory (may be intimidating)
  • Use your script as a service and then start the service at boot.
  • Use crontab with @reboot job.
Biggybi
  • 585
  • 1
    In all of these 3 ways, the commands are asynchronous? They call the next command even if the current didn't over yet? My doubt is if xinit throws a return code, once the screen go white on command line. – Bruno Carneiro Aug 24 '17 at 08:07
0

I have tried what the other 2 answers have suggested and have failed. I have found that your best bet is to set a script for auto startup in your desktop's settings.