So I have this program which I manually run as root :

sudo gammu-smsd -c /etc/gammu-smsdrc -d 

What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .

Is it ok to just edit root's crontab and stick this command there? Or there's some other way?

(Im using Ubuntu 11.04.)

  • 1
    You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root. – Johan Sep 28 '11 at 10:38
  • You might first ask yourself if you want that to be run before or after a user logs in. – rozcietrzewiacz Sep 28 '11 at 11:02
  • 1
    It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you. – whoami Sep 28 '11 at 11:07
  • I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots. – r2b2 Sep 28 '11 at 14:30

How about /etc/rc.local?

This will be executed last in the startup sequence.

| improve this answer | |
  • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script – GusDeCooL May 15 '13 at 16:50

You can use crontab for this.
Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).
Add following line at the end:

@reboot <command>


  • @reboot my_script.sh
  • @reboot python my_script.py arg1 arg2

Finally use contab -l to make sure your script was added to the list.

| improve this answer | |
  • Command 'contab' not found. – zwcloud Nov 3 '18 at 11:39
  • 1
    Use apt-get install cron – Jithin Pavithran Nov 3 '18 at 13:48

Here is how on how to add a startup script to be run at bootup. You can find more information here.

| improve this answer | |
  • 1
    The link you gave is very outdated. From what I know, the booting procedure has much changed since. – rozcietrzewiacz Sep 28 '11 at 11:00

May this help you ?


Or just add it in the /etc/profile

or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/

Indeed, remove the sudo ! (but you will need it to do the edit or to add the command, so...)

| improve this answer | |
  • 1
    it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login – r2b2 Sep 28 '11 at 9:49
  • see my edit : add it in the system-wide startup file – Louis Sep 28 '11 at 10:01
  • Louis: do I need to remove sudo if i follow that guide? – r2b2 Sep 28 '11 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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