WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to start program automatically after system started  (Read 6579 times)

Offline wwwronin

  • Newbie
  • *
  • Posts: 17
How to start program automatically after system started
« on: December 09, 2015, 01:07:50 AM »
How to start program automatically after system started .
And how to load drivers(like video card) automatically.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How to start program automatically after system started
« Reply #1 on: December 09, 2015, 01:50:10 AM »
How to start program automatically after system started .

Start in /opt/bootlocal.sh
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to start program automatically after system started
« Reply #2 on: December 09, 2015, 01:57:19 AM »
Hi wwwronin.

bmarkus beat me but this may provide additional information. If i'm wrong, someone will correct and i'll learn too.

Drivers should be listed in onboot.lst, example xf86-video-intel.tcz.

/opt/bootlocal.sh for programs and commands at boot, especially requiring root, example:
Code: [Select]
#!/bin/sh
# put other system startup commands here

sudo /usr/local/sbin/basic-firewall noprompt
mkdir /mnt/nfs_test
/usr/local/etc/init.d/nfs-server start
/usr/local/etc/init.d/nfs-client start

Plain text document in ~/X.d./ for user/non-root items, example non-executable plain text document named startups containing:
Code: [Select]
amixer set Master 80% &
amixer set PCM 100% &
amixer set Master unmute &
amixer set PCM unmute &
conky &
xset s 300 &
« Last Edit: December 09, 2015, 01:59:05 AM by nitram »

Offline wwwronin

  • Newbie
  • *
  • Posts: 17
Re: How to start program automatically after system started
« Reply #3 on: December 09, 2015, 03:07:07 AM »
That means I should rewrite /opt/bootlocal.sh in tinycore.gz?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How to start program automatically after system started
« Reply #4 on: December 09, 2015, 03:24:48 AM »
/opt/bootlocal.sh  already runs as root. No  sudo  required.

/opt/bootlocal.sh  is by default added to the backup on system shutdown / reboot.

http://tinycorelinux.net/corebook.pdf
Download a copy and keep it handy: Core book ;)

Offline wwwronin

  • Newbie
  • *
  • Posts: 17
Re: How to start program automatically after system started
« Reply #5 on: December 09, 2015, 03:43:37 AM »
I read the cookbook , if I want to start X-Window based program , the startup script must be placed at ~/.X.d .I try to start editor program when system is loaded, that takes effect. But  it seems that we must change the permission of files put in dir ~/.X.d . Is this correct ?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14817
Re: How to start program automatically after system started
« Reply #6 on: December 09, 2015, 04:00:14 AM »
The permissions should be tc:staff

Offline nitram

  • Hero Member
  • *****
  • Posts: 1054
Re: How to start program automatically after system started
« Reply #7 on: December 09, 2015, 05:16:27 AM »
Thanks Misalf, noticed my sudo entry after the fact, remnant of newbier days :)

wwwronin file(s) in ~/.X.d. are NOT scripts, just plain text files named whatever. You can have multiple entries in a single file. Or create multiple files with a single entry in each file. The permissions are of course tc:staff, provided you're running as tc, as it's in your home directory. You do NOT need to  chmod +x  or anything, it's NOT a script.

So you could do...

filename: ~/.X.d./10_editor
entry: editor &

filename: ~/.X.d./20_firefox
entry: firefox &

....or just one simple file named ~/.X.d./startups containing:

editor &
firefox &

Offline wwwronin

  • Newbie
  • *
  • Posts: 17
Re: How to start program automatically after system started
« Reply #8 on: December 09, 2015, 05:56:47 AM »
Thanks a lot

Offline wwwronin

  • Newbie
  • *
  • Posts: 17
Re: How to start program automatically after system started
« Reply #9 on: December 09, 2015, 06:49:26 AM »
 I use command like this "editor &" ,when system is started ,there a  two editor windows .  Why is that?