Is there any config file that is evaluated once, everytime operating system starts up. bashrc does not qualifies since it gets evaluated everytime a gnome terminal starts..
Is there any config file that is evaluated once, everytime operating system starts up. bashrc does not qualifies since it gets evaluated everytime a gnome terminal starts..
cron can be of help here.
Besides starting something on a minute,hour,day of week, month etc it also has some special operations:
Editing is done from command line with the following command:
sudo crontab -e
at the bottom of the file (below the
# m h dom mon dow command
) you can add a line that executes what you want like so@reboot /directory/to/file
will execute /directory/to/file during boot.Just one warning: you need to make sure that there is no output from that script or that the output is redirected to a file (or /dev/null) since there is no display for cron to send the output (and it will end the operation).
Example
sudo crontab -e
and...
Now for a reboot... And here is a working example:
Beside other answers, you can put your startup (superuser) commands in
/etc/rc.local
.There are 2 places I use when I need to add "run-once" commands:
Once at every user login (be it Graphical/GDM or text/console login):
~/.profile
Pros:
Cons:
dash
Once when GDM starts (before any user logs in):
/etc/gdm/Init/Default
Pros:
Cons:
gdm
user. So personal scripts and path to them must be world-readable and executableUse the method that suits your need.
Have you looked into cron jobs? You can set one at reboot
@reboot
in your crontabJust add commands to
/etc/rc.local
. It is executed once at the end of the boot process. Make sure you exit with error code 0.I use this on other computer since... since... well, probably Ultrix in 1989. You have to make sure your script works invoked as root and without graphical interfaces. A way to test it is running it form a virtual console (Ctrl-Alt-F1, Ctrl-Alt-F7 to go back to your graphical environment) in a root shell (
sudo -i
).Be warned that a wrong command in that shell can completely destroy your system.
In addition to the crontab solution: You can do this (as root) noninteractively via
and put into this script a
for removing it again. Else the script will be executed after every reboot.