Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Start a own written program at boot

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
rasidrasid
Posts: 4
Joined: 2018-09-14 12:14

Start a own written program at boot

#1 Post by rasidrasid »

Hello,

I am using wheezy as a server (without a Desktop). I wrote a program that I want to start at startup/at boot. This program is actually in my home directory. So please, how can I link it, move it or do it somehow to start it in the boot phase? Thanks.

Regards

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1389
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 66 times

Re: Start a own written program at boot

#2 Post by None1975 »

Hello. Check this. Maybe you will find this link helpful.
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

rasidrasid
Posts: 4
Joined: 2018-09-14 12:14

Re: Start a own written program at boot

#3 Post by rasidrasid »

Thank you. I thought it would be easy like link it to any runlevel or so :D
It could be that I be wrong.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Start a own written program at boot

#4 Post by GarryRicketson »

Some more details on this "program" would help, is it really a program or
just a script, ?
You might be able to start it using the '/etc/rc.local'
also " init.d " or ' crontab ' are options.

Code: Select all

man init.d

Code: Select all

man crontab 
Did you try searching, using these :

Code: Select all

How to make a program start at boot on Debian 7 wheezy 
key words ?

HankB
Posts: 53
Joined: 2012-03-07 15:15

Re: Start a own written program at boot

#5 Post by HankB »

You can run something from cron at boot from the man page for crontab(5)

Code: Select all

man 5 crontab
...
 Instead of the first five fields, one of eight special strings may appear:

              string         meaning
              ------         -------
              @reboot        Run once, at startup.
              @yearly        Run once a year, "0 0 1 1 *".
              @annually      (same as @yearly)
              @monthly       Run once a month, "0 0 1 * *".
              @weekly        Run once a week, "0 0 * * 0".
              @daily         Run once a day, "0 0 * * *".
              @midnight      (same as @daily)
              @hourly        Run once an hour, "0 * * * *".
...
You can put this in your crontab file with the command `crontab -e` or in the root crontab by running that command as root.
If you haven't worked with cron before, be aware that it runs the commands with a stripped down environment - not your login environment. For example if your program is ~/bin/command you would need to specify '/home/username/bin/command' in the crontab file. It is also wise to redirect output somewhere you can look at it in case the job doesn't produce the desired results. '>/tmp/command.txt 2>&1` will work for sh or bash shells. I'm afraid I don't recall which shell cron uses to run commands.

/etc/rc.local would be the easiest way but I don't see it on my systems so I don't know if it still works.

You can also configure this using systemd but that takes a bit more work. However it can provide the benefit of restarting your program if it crashes.

HTH,
hank

rasidrasid
Posts: 4
Joined: 2018-09-14 12:14

Re: Start a own written program at boot

#6 Post by rasidrasid »

Hello.

Thank you all.
The program is a script, yes thas true :D

Until now I tried this: I put a softlink (ln -s) in every runlevel with a "S" letter at start of the name. But it wont worked. I did the same in /etc/init.d, but without success.

I overcome such a problem in former times exactly like that, but the os was ubuntu. Now I want to do this with debian :wink:

regards

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Start a own written program at boot

#7 Post by GarryRicketson »

Ok, well, here is one that applies to Bash scripts, and using /etc/rc.local :
https://serverfault.com/questions/73562 ... s-of-shell

If it is not a bash script, but perl (for example), it still could be used, with some
modification.
This might be of help to you as well:
https://debian-administration.org/artic ... ith_Debian

rasidrasid
Posts: 4
Joined: 2018-09-14 12:14

Re: Start a own written program at boot

#8 Post by rasidrasid »

Thanks. I will try it.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Start a own written program at boot

#9 Post by debiman »

please be aware that wheezy has been outdated & EOL for a long while now.
you really should upgrade.
in any case, no solution involving systemd will work.

Post Reply