is there a command in centos to dynamically add entries to the inittab file? - centos5

is there a command in centos to dynamically add entries to the inittab file ? I am writing a new daemon and would like the init to restart it when it dies for any reason.

Can you add the entry with echo, or whatever, then use initctl as necessary?

Related

How configure multiple Redis instances on Debian

I've got a Debian server running Redis and I'd like to run a second copy using a different port. There are plenty of guides explaining how to do it on Ubuntu and other flavours of Linux but I'm having a hard time translating those to Debian.
So far I've created a copy of the /etc/redis/redis.conf and have renamed it /etc/redis/redis_6380.conf. In the new file I've changed the name of the PID file, location of the log file, the listening port (to 3680) so that they do not conflict with the existing instance of Redis.
The problem I have is knowing which changes to make so that systemd can start the new instance.
I've made a duplicate of /lib/systemd/system/redis-server.service and called it redis-server-6380.service and have changed the EXECStart and PIDFile lines to point to the new files:
ExecStart=/usr/bin/redis-server /etc/redis/redis_6380.conf
PIDFile=/var/run/redis/redis-server_6380.pid
Doing:
systemctl enable redis-server-6380.service
results in:
Failed to enable unit: File /etc/systemd/system/redis.service already exists and is a symlink to /lib/systemd/system/redis-server.service
How do I fix this ? I'm guessing that I've missed out a vital step but I'm not that familiar with configuring systemd supervised processes on Debian.
The end of the redis-server unit file would say:
[Install]
WantedBy=multi-user.target
Alias=redis.service
Either remove that Alias, or make sure it would be unique.
Also: make sure your Redis instances would have their own database and log files.

Redis nodes.conf file locked?

I am following this tutorial to create a Redis cluster:
http://redis.io/topics/cluster-tutorial
In this tutorial I need to run several redis-server instances on port 7000 through 7005. However after I run the first instance successfully and try to run the second instance the nodes.conf file seems to be locked and I get the following error message:
"Sorry, the cluster configuration file nodes.conf is already used by a different Redis Cluster node. Please make sure that different nodes use different cluster configuration files."
Do I need a separate nodes.conf for every server instance? Or do I need a separate redis-server executable in each instance directory and run it from there?
The tutorial suggests you to use separated folders for each instance configuration, so each instance will also generate the nodes.conf on its own folder.
Create a redis.conf file inside each of the directories, from 7000 to
7005.
You need to have the .conf files on separated folders for each instance, and the executable must be ran from that folders.
Assuming you have the redis-server on /tmp/redis-cluster/, and the redis.conf on each /tmp/redis-cluster/700x folder:
cd /tmp/redis-cluster/7000
../redis-server ./redis.conf
This way the nodes.conf will be generated on the current folder 7000.
Note that you must first issue a cd to change the current directory, and from that folder execute the redis-server that is one folder up (../)

tmux : config files are not used

I use tmux (tmux 1.8) from Ubuntu 14.04.
I wanted to configure it a bit via ~/.tmux.conf. But whatever I set inside this file my tmux session looks the same. Then I tried a fresh new /etc/tmux.conf but I still get the same display.
It seems that my config is hardcoded and that I cannot change it.
If I remove these two files (~/.tmux.conf and /etc/tmux.conf) my tmux session is still the same. Tmux runs but I can not configure it. But it should be so simple...
Does anybody have already seen this? And how I could solve that? Do I need to compile a fresh new release of tmux?
Today, I have more details :
on one machine it works as expected. It's OK. But I did not changed anything! Strange...
But on another machine (also running Ubuntu same release and up2date like the first machine) it does not work.
The file /etc/tmux.conf does not exist on none of these 2 machines. I put this little config file (~/.tmux.conf) :
# start Window Numbering at 2
set -g base-index 2
When I launch tmux on this second machine, window numbering starts at 0. On the first machine with the same config file, it behaves correctly : it starts at 2.
I'm going crazy!
After you make changes to ~/.tmux.conf make sure tmux sources them with the tmux source-file ~/.tmux.conf shell command.
Try removing all sessions before running tmux. I have noticed that if you have sessions still running, tmux will still load the previous .tmux.config file.
Executing tmux kill-server can stop the server and then try to run the server again using tmux command.
Please note that after killing the server you will lose all open sessions / tabs.

Delete old tmp file when Apache starts

I'm using Bitnami MAMP Stack on OSX and would like to clear the tmp directory whenever I start the Apache Web Server.
So basically I need to know where to add the following command, or a script containing the command rm -rf ~/Library/Containers/com.bitnami.mampstack/Data/app/php/tmp.
Takk,
Robert.
Just look inside your MAMP program folder. There is ./bin/start.sh
Just add you line to this.
Or to startApache.sh if you want to execute only with Apache restarts.

what happen if i delete apache log file?

I have 4 files in /var/log/apache2 and I just deleted 2 of them (I do have backups). would it affect apache's logging capabilities? does apache automatically create files and write to them if they don't exist?
It will create new file automatically.
The file is deleted but the file handle remains until you reload/restart apache, at least on Rhel 7.
You can verify this by running sudo lsof | grep access_log after deleting /var/log/httpd/access_log.
You might see the file automatically getting recreated some time later when logrotate runs, as that issues a reload which would then trigger the file to be created again.