Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way to add an application/script to the Linux startup so every time the system is on it executes [i'm looking for some automated way, user should not add this by cron job or something like that].
Yeah you are right, i want to create a little cute virus :) and also want to know if it is possible.

share|improve this question
    
See also this SO answer: Run automatically program on startup under linux ubuntu –  knoxxs Jul 19 '12 at 14:36
add comment

migrated from stackoverflow.com Aug 29 '11 at 2:08

This question came from our site for professional and enthusiast programmers.

6 Answers

up vote 5 down vote accepted

Something like Cron?

Note the @reboot entry

This is the most flexible approach, and the one most like Windows' "Scheduled Tasks" (better actually).

share|improve this answer
    
is it possible to add a job in CRON without user's intention ? –  Sourav Aug 16 '11 at 15:01
    
yes. just write to /etc/cron.d, or call crontab from your program without them knowing. –  awoodland Aug 16 '11 at 15:07
    
What do you mean? If you mean manually add one programatically, then yes. Crontabs are just text files. –  kevlar1818 Aug 16 '11 at 15:07
add comment

Yes, one simple way to add entries to /etc/rc.local

share|improve this answer
    
adding entry in the file will start the program each time ? –  Sourav Aug 16 '11 at 15:01
1  
Each time you reboot, yes. If you want regularly scheduled jobs (every day, hour, week, or any odd combination) then the cron scheduler is your friend. –  Dirk Eddelbuettel Aug 16 '11 at 15:02
add comment

Write your own script for /etc/init.d

share|improve this answer
add comment

Apart from system-level startup script your desktop environment might have its own way of auto-running programs. The folder .config/autostart is supposed to be a desktop-neutral way of defining autorun entries. See the spec at http://developer.gnome.org/autostart-spec/.

It is a bit different if you need to run your scripts after the network is up and running. In that case you should check the special post-connect scripts that can be defined for your network manager. Both NetworkManager and wicd have their own ways of specifying post-connect autorun entries.

share|improve this answer
add comment

Each distribution uses each own bootstrap technique, so need to look at docs for your distro. /etc/rc.local is a place where you can put some automated scripts, but it is really outdated. Now most of linux based systems uses runlevels or systemd bootstraping, so most of autostarted jobs could be fine-grade controlled.

share|improve this answer
add comment

I found my answer here: http://stackoverflow.com/questions/7221757/run-automatically-program-on-startup-under-linux-ubuntu I was able to create a file / script to turn off my trackpad while I in my Linux Ubuntu 12.10 session.

share|improve this answer
1  
Glad you found a solution, could you include a summary of the steps in your answer, just so this answer is a more useful than just a link. Thanks! –  slm Apr 24 '13 at 4:15
    
Was looking for a way to automate and turn off my trackpad at startup. The command I entered in Terminal was 'sudo modprobe -r psmouse' This would turn off the trackpad while in the current session. I wanted to automate this at boot. I did some research and wrote a script by modifying the file /etc/rc.local, adding 'sudo modprobe -r psmouse. Then issuing the following commands from Terminal: 'sudo mv /filename /etc/init.d/' 'sudo chmod +x /etc/init.d/filename' 'sudo update-rc.d filename defaults' Now the touchpad is off at startup. –  CatGuyTX Apr 25 '13 at 5:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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