You are not logged in.

#1 2011-01-03 15:45:01

avanc
Member
Registered: 2010-12-21
Posts: 12

Execute program after boot

Hi,

I use some Bash scripts to make backups of my data using rsync and cp -l.
To decide at boot time, if a backup should be made, I append DOBACKUP=yupp (yupp=yes, see problem below) to the kernel line in Grub. The variable DOBACKUP can be accessed within the init environment. I added a simple rc.d scripts that checks if the variable is set and starts the backup. However, this is not the nicest way, since the boot of the system is not finished yet. If the backup script hangs, I don't have any console. How can I execute a program after the computer is booted?
Furthermore, I don't want to execute the backup script in the background, since it asks for some user input.

What is the correct way in doing this?

Another strange behavior occurs, if I set DOBACKUP=yes. In this case, I get a blank screen and not boot output is shown (but it seems that the computer boots correctly, just without any output on the monitor). Thus I use yupp instead of yes to indicate the need for a backup: DOBACKUP=no or DOBACKUP=yupp work both as expected.

Sven

Offline

#2 2011-01-03 18:10:14

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Execute program after boot

avanc wrote:

I don't want to execute the backup script in the background, since it asks for some user input.

Seems clear to me that you need a logged-in user to provide user input - run the script from your shellrc at login time.

Offline

#3 2011-01-03 18:11:51

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Execute program after boot

tomk wrote:
avanc wrote:

I don't want to execute the backup script in the background, since it asks for some user input.

Seems clear to me that you need a logged-in user to provide user input - run the script from your shellrc at login time.

Either that, or the script should be refactored to not require user input.

Also, the kernel command line is always available via /proc/cmdline.

Offline

#4 2011-01-03 18:34:39

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Execute program after boot

Also, this is not a General Programming issue, moving to Workstation User.

Offline

#5 2011-01-03 20:17:36

avanc
Member
Registered: 2010-12-21
Posts: 12

Re: Execute program after boot

falconindy wrote:
tomk wrote:
avanc wrote:

I don't want to execute the backup script in the background, since it asks for some user input.

Seems clear to me that you need a logged-in user to provide user input - run the script from your shellrc at login time.

Either that, or the script should be refactored to not require user input.

Deamonize the backup script? In that case I don't get any feedback if everything works fine.

My intention is to install arch on a USB disk. A windows user can plug the disk in and start the computer. Arch Linux is booted from the USB disk and the backup is automatically started. However, a short message that everything worked fine before the script shuts the PC down would be preferable.
To keep the backup simple, the login idea is also not the best choice...

Offline

#6 2011-01-07 20:45:41

Knute
Member
From: Minot, ND
Registered: 2009-03-17
Posts: 604

Re: Execute program after boot

Send an email notification whether it succeeded or not.  That way, you wouldn't need user intervention, nor would you have to sit and wait for it to finish.  Simply check your email to find out.

And if the system is not on the net, well, you can always store such notifications on the flash drive.


Knute

Offline

#7 2011-01-07 23:24:36

os
Member
Registered: 2010-12-29
Posts: 6

Re: Execute program after boot

If you don't want to receive an email or don't have sendmail (or similar) intalled on your system you could of course also think about creating a log file.

Offline

#8 2011-01-08 14:06:34

avanc
Member
Registered: 2010-12-21
Posts: 12

Re: Execute program after boot

Sure, a logfile is created. But hwo often do you check those ;-)

Another idea that came into my mind: Can a add another program instead of agetty in /etc/inittab? Of course without respawn...

Offline

Board footer

Powered by FluxBB