Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to run the simple shell command echo 1 > /proc/sys/kernel/sysrq at each boot, to enable the sysrq keys. When in boot should this be done, and where should I put a script to do it?

share|improve this question
All Linux distributions already sets the time. Maybe the battery to your RTC on the motherboard is low? – Joachim Pileborg Sep 10 '12 at 6:35
@JoachimPileborg actually there is no RTC on my motherboard :) It's a embedded system board without RTC. – Peter Sep 10 '12 at 6:43
Also… – davidgo Dec 8 '13 at 7:34
I beg to differ, @davidgo. The references you are quoting are a tad obsolete: while crontab does work, /etc/rc.local does not on systemd distros like Arch Linux. By referring to them, we might be sending Demetri on a wild goose chase. Some updating, at times, needs to be done. – MariusMatutiae Dec 8 '13 at 7:41

3 Answers 3

up vote 15 down vote accepted

Depends on distros.

If you are on Debian-derived distros, there are at least two proper places, /etc/rc.local and crontab. You may invoke crontab as root,

   crontab -e

and then insert this line

   @reboot /home/my_name/bin/my_command

where my_command is an executable file (chmod 755 my_command).

Alternatively, you may place a line like this


in /etc/rc.local, and this will be executed last. In any case, pls do remember you are using root environment, not yours. Also for this reason, it is best to use absolute paths.

If you are on a systemd distro (Arch Linux, Fedora 19,...) the first option (crontab) is still valid, while the second one (/etc/rc.local) does not exist any longer. In this case, you should learn how to start a service to be run by systemctl, but this may be more than you bargained for with your simple question.

share|improve this answer
Can you confirm this for Fedora ? My searching tells me that rc.local will still run if it exists and is executable, but is not set up by default. I perceived troubling ramifications if rc.local does not run ! (I could only find references for this for Fedora 18 - – davidgo Dec 8 '13 at 7:43
You are right, in Fedora 19 you might still have it, if you really want it. But it is no longer packaged,… bullet 3.2.4. Also, it does not exist in Arch Linux altogether, so I thought it safe to include a warning about that. – MariusMatutiae Dec 8 '13 at 7:49
maybe this is an unknown alias for me but @boot does not exist, just @reboot – Zarathustra Sep 14 '14 at 0:00
@Zarathustra thanks for pointing this out, I corrected it. – MariusMatutiae Mar 15 at 21:01

If your system is running a version of cron that supports it (specifically Vixie cron), you can use @reboot in a cron job.

This is one of 8 special strings that it supports.

Quoting the crontab(5) man page (from my Ubuntu 12.04 system):

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 * * * *".

Please note that startup, as far as @reboot is concerned, is the time when the cron(8) daemon startup. In particular, it may be before some system daemons, or other facilities, were startup. This is due to the boot order sequence of the machine.

This is far from being the only way to run something at boot time, but it's an alternative.

share|improve this answer

This question shows a lack of even basic research. Pretty much all variants of Linux (going back a long, long time) have a file /etc/rc.local which runs on startup - you can just add the command to it.

That said, you don't even need to do that. The "correct" way would be to modify / add the line kernel.sysrq = 1 into /etc/sysctl.conf

share|improve this answer

Your Answer


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.