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.

I have set up a bridge between eth0 and wlan0 with netctl. It works fine if I tell it to configure eth0 and wlan0 at startup and then for me to manually start the bridge after it boots. If I tell the bridge to start automatically as well though for some reason the wlan adapter does not connect to an access point. I therefore need "netctl start bridge" to run a minute or so after the entire system has finished booting. Any idea how I should do this?

PS. This is a headless system as in no xorg so running it at xorg startup won't work.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Arch uses systemd to manage startup processes (daemons and the like as well).

You can write a script that simply executes the command that you want, or sleep for a min and then execute. Then add it to the boot process with the instructions on the

wiki

if you add a sleep:

#!/bin/sh
sleep 60 # one min
netctl start bridge

It should work perfectly fine. Systemd should spawn another process when it executes your script so it shouldn't make your system hang.

share|improve this answer
    
Well that's obvious but I have no idea how to make it start at the right time –  Gerhman Jun 20 at 14:12
    
add a sleep to is #!/bin/sh sleep(60) # one min netctl start bridge It shouldn't cause the system to hang as it should be spawned as a separate process. –  Livinglifeback Jun 20 at 14:14
    
Could you please just give me an example file for this as I'm a bit to unexperienced to know how to implement that. –  Gerhman Jun 20 at 14:17
1  
The parens in "sleep(60)" are not necessary or syntactically valid for shell scripts. –  godlygeek Jun 20 at 14:46
3  
sleep in a systemd startup script is contrary to the purpose of having a systemd startup script. –  mikeserv Jun 20 at 17:08

You can use systemd timers to execute script a minute after boot.

First, create service file (/etc/systemd/system/myscript.service):

[Unit]
Description=MyScript

[Service]
Type=simple
ExecStart=/usr/local/bin/myscript

Then create timer (/etc/systemd/system/myscript.timer):

[Unit]
Description=Runs myscript every hour

[Timer]
# Time to wait after booting before activation
OnBootSec=1min
Unit=myscript.service

[Install]
WantedBy=multi-user.target

Now enable and run it:

# systemctl enable myscript.timer
# systemctl start myscript.timer
share|improve this answer
    
Couldn't you add an after line so the script runs after wlan0 is configured? –  StrongBad Jun 20 at 19:12
    
@StrongBad, probably you can add Requires=sys-subsystem-net-devices-wlan0.device and After=sys-subsystem-net-devices-wlan0.device to service to ensure that it will start after wlan0 configuration. But I haven't tested it by myself. –  diffycat Jun 20 at 19:27

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.