Avatar of Alex Matzinger
Alex MatzingerFlag for United States of America

asked on 

Adding a command to run at boot time in RedHat 5

Hello,

I am trying to get a command to run at boot up on my RedHat 5 linux machine.  The command is
synergyc 111.111.111.111 &

Open in new window

I have added the command to my /etc/rc.d/rc.local file, but it still does not run.  I was wondering how i can get it to run.  Thank you.
Linux DistributionsLinux OS Dev

Avatar of undefined
Last Comment
Alex Matzinger
Avatar of AriMc
AriMc
Flag of Finland image

The first thing to check is the file permissions as sometimes text editors remove the execute right from files when saving. So do a "ls -al /etc/rc.d/rc.local" and make sure there it looks like:

-rwxr-xr-x 1 root root 306 2009-03-08 20:35 rc.local

The 4th character "x" is the most important one.

Avatar of HawyLem
HawyLem

Try to make it as a script and add it to the rc.local file

http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

It should run at boot if it is in the rc.local file, you may not be getting the results you want because the network is coming up AFTER the command runs.  I am familiar with synergy. ;)

Try putting it in the startup programs in gnome.  It will start when you log in as the user and the network will be up already.

Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Also another work around would be to put a sleep in front of it.

sleep 5; synergyc 111.111.111.111 &

Although this will slow down your boot up by 5 seconds. :)
Avatar of Alex Matzinger

ASKER

@AriMc
I have made sure that the file is execuatble.

@HawyLem
I have tried the methods on that link as well.  Red Hat doesn't support 'update-rc.d' ( i also tried some of the methods in the comments of that page and couldn't get it to work)

@savone
I tried the sleep command and still nothing.  I think you are right about the network not being up when the command is being run.  I think i may just have to deal with logging in before the command starts.
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

That's what happened to me, so I added it in the gnome startup apps and it worked great.
Avatar of de2Zotjes
de2Zotjes
Flag of Netherlands image

rc.local is the very last bit of code that is run as part of the boot process. On an old-fashioned setup the network is up by that time. Newer installations that depend on network manager for the network connectivity will not provide connectivity until a user (who configured a network connection) logs in.

Depending on the role the machine fulfills you might want to promote your personal network configuration settings to system settings. Doing that and changing the setting [ifupdown] managed=false to managed=true should get you earlier connectivity.

You can even -if the box is a desktop- just use system-config-network to setup the connectivity
Avatar of oppofwar
oppofwar

Open /etc/rc.sysinit and enter the command on the last line , it will run before network starts
Avatar of oppofwar
oppofwar

ignore the previous comment , You have to enter it on the line before hostname is specified

ie. vi /etc/rc.sysinit

------Enter it here------
HOSTNAME=`/bin/hostname`

...............

Avatar of Steven Vona
Steven Vona
Flag of United States of America image

@oppofwar - He needs it to run AFTER the network is up.
Avatar of Monis Monther
Monis Monther
Flag of Iraq image

Did you ever try using the full path of the command in your rc.local file??

The PATH variable has not been initialized yet to find your commands under /sbin/ usr/sbin ..etc

Now just to make things clear

1- rc.local is the last file excuted during a boot process and networking comes up much before that. You can examine that by yourself by pressing the letter ( i ) when booting up your machine at the stage where it says welcome to Red Hat Enterpise Linux press i for interactive booting.

2- commands under rc.local must be written using the full path of the command

3- I am not really sure of what the command does but if its something graphical then you need to set display and x-sessino info in the rc.local its not going to popup things for you. Otherwise if its a command that would run in the backgroun then it will be fine.
Avatar of Alex Matzinger

ASKER

I have tried using the fill path of the command (/usr/bin/synergyc)  and it still does not work.  I am fairly certain that for this program i have to be signed in to allow it to work.  Not the end of the world, just means that i have to continue using two keyboards to log in.

Oh, and synergy is a program that allows a user to use one keyboard and mouse across multiple platforms(such as if you have a windows and linux or Mac machine side by side, you can use one keyboard and mouse to control them all)
ASKER CERTIFIED SOLUTION
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Alex Matzinger

ASKER

I have added it to my gnome start up, so currently once i log in it starts up.  I'm going to leave this question up a little longer just in case before i split the points up.
Avatar of de2Zotjes
de2Zotjes
Flag of Netherlands image

Depending on how strict the security for that box has to be you could setup automated login for it: http://www.linfo.org/automatic_login.html.
That way you no longer need 2 keyboards on your desk :)
Avatar of Julian Parker
Julian Parker
Flag of United Kingdom of Great Britain and Northern Ireland image

Adding to /etc/rc.d/rc.local should be fine, the network is already up at this stage. The docs for synergy seem to require a -f option so you may need something like;

   /path/to/synergyc -f <ipaddress>

However, it may need X to be running for the session to work correctly in which case you need to add to the X startup (mentioned by savone above)

Are there any errors in the log files?
Avatar of Alex Matzinger

ASKER

-f is just for running the program in the foreground to verify it is working, but is not required.  I haven't found any errors in the log files.  For this program it appears that i'm just going to have to be satisfied with starting it when i log into the machine.
Yes, X does have to be running to start synergyc
See http://synergy2.sourceforge.net/autostart.html
Avatar of Alex Matzinger

ASKER

It does not appear that i can get this to run on boot up, so the best solution is to make it start when i log in
Linux Distributions
Linux Distributions

A Linux distribution is an operating system made as a software collection based on the Linux kernel and, often, on a package management system and are available for a variety of systems. A typical Linux distribution comprises a Linux kernel, GNU tools and libraries, additional software, documentation, a window system (the most common being the X Window System), a window manager, and a desktop environment. Most Linux systems are open-source software made available both as compiled binaries and in source code form, allowing modifications to the original software. Over three hundred distributions are in active development, including commercially backed distributions (such as Fedora, openSUSE and Ubuntu) and community-driven distributions (such as Debian, Slackware, Gentoo and Arch Linux).

29K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo