LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Not able to add program to startup (https://www.linuxquestions.org/questions/linux-newbie-8/not-able-to-add-program-to-startup-887525/)

henfos 06-21-2011 07:13 AM

Not able to add program to startup
 
Made a little c-program i want to start at boot and found out that i can do that through the rc.local script that runs once every time the computer boots. Say that i have a program called test in /home/user/Documents... what do i write rc.local? Know nothing about scripting and i didnt understand what i read when i googled it :/

DJ Shaji 06-21-2011 07:22 AM

Just add a line to rc.local containing the full path to the program you want to run. For example, if I want to run /home/djshaji/Documents/personal/new/c-programs/bin/hello_world, I would simply put the entire path to the program in rc.local. No need to do any scripting.

austinium 06-21-2011 07:22 AM

On Gnome you could type
Code:

gnome-session-properties
in a terminal and then add the program you made to the list of Startup Applications.

This works on Gnome 2.30.2, don't know about the newer versions.

henfos 06-21-2011 07:29 AM

Quote:

Originally Posted by DJ Shaji (Post 4391644)
Just add a line to rc.local containing the full path to the program you want to run. For example, if I want to run /home/djshaji/Documents/personal/new/c-programs/bin/hello_world, I would simply put the entire path to the program in rc.local. No need to do any scripting.

And thats what i thought, but when i do that and run the script directly or do a reboot my program never starts. I know because if it starts the first thing it does is write "test" to a textfile, and it runs perfectly if i just run the program directly. :(

henfos 06-21-2011 07:41 AM

btw. when i run the script in terminal i get segmentation fault...

henfos 06-21-2011 07:55 AM

lol, ill just continue to answer myself so you know where im at. So ive found out that there is no problem with the rc.local script, just that i get segmentation fault. What is this? I can run the applikasjon from window, but not through rc.local

henfos 06-21-2011 08:55 AM

Another rc.local problem :/
 
Okei, i was a bit quick to push the solved button on my other thread so sorry for spamming the forum :P (Really noob;))
My program now starts during the boot through the use of rc.local, but its not still running when i login and check system monitor. My program is essentially an while-loop so it isnt quiting by itself.

chrism01 06-21-2011 06:33 PM

Really you'd have been better to add to the orig qn I think.
Can you point at or describe/summarise the orig qn for me/us?

Edit: OK, just stumbled across it.

Basically

1. fix the segment violation
2. the entry in rc.local should like something like this
Code:

nohup /dir/myprog > /dir/myprog.log 2>&1 &

HTH
:)
http://rute.2038bug.com/index.html.gz

Tinkster 06-21-2011 06:41 PM

I merged your two threads and marked the resulting one as "unsolved".



Cheers,
Tink

DJ Shaji 06-27-2011 07:09 AM

OP: You've got to give a little more info, man! If you could share the code of your program, or at least to the point where it segfaults, that'd be great. In the meantime:

1. Where is the file to which your application writes "test"? if you fopen() a file that doesn't exist, the function would return a null pointer, and if you mess around with a null pointer, you're bound to get a SEGV

2. Drink Pepsi
3. Use full paths wherever possible in your program.

chrism01 06-27-2011 06:19 PM

SIGSEGV in C is typically caused by overwriting the end of a char 'string' or an array.
A typical gotcha in re (1) is to forget about the '\0' reqd at the end of a string and write a 'normal' char over it, thus removing the EOS (end-of-string) marker that the C string fns rely on.


All times are GMT -5. The time now is 12:16 PM.