start-stop-daemon error (Exec format error) - upstart

This command is part of an upstart script, which used to work in ubuntu 12.04, 10.04.
sudo start-stop-daemon --start --make-pidfile --pidfile /var/run/mk_order_handler.pid --chuid ubuntu --exec /data2/src/jeapps/sites/crons_index.php workers/mk_order_handler
I just upgraded my system to 14.04 and upstart script stopped working. When I manually executed the start-stop-daemon command I get Exec format error.
The only difference I can see is, the script is placed in a separate block device. Will it cause a problem? How could I fix this error?

I just now had the same issue and in my case it was due to that my script lacked the #!/bin/bash in the first row.

You should separate arguments from the executable path using --.
The result would be:
start-stop-daemon --start --make-pidfile --pidfile /var/run/mk_order_handler.pid --chuid ubuntu --exec /data2/src/jeapps/sites/crons_index.php -- workers/mk_order_handler
Also, I do not know why you are using sudo. Upstart jobs are run as root, so they do not need sudo.

Related

cannot execute binary file centos?

I am using centos 6.9 and want to install xampp. But when I run the command on the terminal it showing error i.e. cannot execute binary file. So, How can I fix this problem and successfully install xampp ? Please help me.
chmod +x xampp-linux-x64-7.0.22-0-installer.run
./xampp-linux-x64-7.0.22-0-installer.run
after this command it showing
bash: ./xampp-linux-x64-7.0.22-0-installer.run: cannot execute binary file
You're probably running the install (binary) with a lesser privileged user. You'll have to use root user for modifying SELinux settings as such:
semanage fcontext -a -t httpd_sys_script_exec_t '/<install-location>(/.*)/?'
restorecon -R -v /<install-location>/

Mongo doesn't start on fresh install on Ubuntu 14.04

After installing mongodb on 14.04, mongo doesn't work out of the box:
$ sudo apt install mongodb-server
[...]
$ sudo start mongodb
mongodb stop/waiting
What's happening here, how can I fix it?
TL;DR: change no to yes in /etc/default/mongodb and restart the service
The interesting part is in the upstart script (/etc/init/mongodb.conf), at line 19 and 21:
[...]
script
ENABLE_MONGODB="yes"
if [ -f /etc/default/mongodb ]; then
. /etc/default/mongodb
fi
if [ "$ENABLE_MONGODB" = "yes" ]; then
exec start-stop-daemon --start --quiet --chuid mongodb \
--exec /usr/bin/mongod -- --config /etc/mongodb.conf
fi
end script
So if ENABLE_MONGODB is yes, mongod starts and everything is good. It is set to yes in the script, but /etc/default/mongodb is sourced.
A peek inside /etc/default/mongodb shows the problem:
ENABLE_MONGODB="no"
I don't know why this ships disabled, change it to yes and you'll be fine after a sudo restart mongodb.

Automation of Cygwin configuration with PowerShell

I have installed Cygwin using PowerShell scripting.
I am doing the following step manually:
Running a new cygwin bash shell (after the edit of cygwin.bat) and enter:
mount --change-cygdrive-prefix /
chmod +r /etc/passwd /etc/group
chmod 755 /var
Start Cygwin bash shell and run ssh-host-config. Answer yes to all the key generation questions.
Is it possible to automate these things in PowerShell scripts, like installing Cygwin, then doing steps 1 and 2 in a single shot?
Use this command:
bash.exe ssh-host-config --yes -u "Cygwinuser" -c "binmode ntsec tty" -w "pwd#123"
cygrunsrv -S sshd
Later go to services.msc to check if the service is running or not

Upstart / init script not working

I'm trying to create a service / script to automatically start and controll my nodejs server, but it doesnt seem to work at all.
First of all, I used this source as main reference http://kvz.io/blog/2009/12/15/run-nodejs-as-a-service-on-ubuntu-karmic/
After testing around, I minimzed the content of the actual file to avoid any kind of error, resulting in this (the bare minimum, but it doesnt work)
description "server"
author "blah"
start on started mountall
stop on shutdown
respawn
respawn limit 99 5
script
export HOME="/var/www"
exec nodejs /var/www/server/server.js >> /var/log/node.log 2>&1
end script
The file is saved in /etc/init/server.conf
when trying to start the script (as root, or normal user), I get:
root#iof304:/etc/init# start server
start: Job failed to start
Then, I tried to check my syntax with init-checkconf, resulting in:
$ init-checkconf /etc/init/server.conf
File /etc/init/server.conf: syntax ok
I tried different other things, like initctl reload-configuration with no result.
What can I do? How can I get this to work? It can't be that hard, right?
This is what our typical startup script looks like. As you can see we're running our node processes as user nodejs. We're also using the pre-start script to make sure all of the log file directories and .tmp directories are created with the right permissions.
#!upstart
description "grabagadget node.js server"
author "Jeffrey Van Alstine"
start on started mysql
stop on shutdown
respawn
script
export HOME="/home/nodejs"
exec start-stop-daemon --start --chuid nodejs --make-pidfile --pidfile /var/run/nodejs/grabagadget.pid --startas /usr/bin/node -- /var/nodejs/grabagadget/app.js --environment production >> /var/log/nodejs/grabagadget.log 2>&1
end script
pre-start script
mkdir -p /var/log/nodejs
chown nodejs:root /var/log/nodejs
mkdir -p /var/run/nodejs
mkdir -p /var/nodejs/grabagadget/.tmp
# Git likes to reset permissions on this file, but it really needs to be writable on server start
chown nodejs:root /var/nodejs/grabagadget/views/layout.ejs
chown -R nodejs:root /var/nodejs/grabagadget/.tmp
# Date format same as (new Date()).toISOString() for consistency
sudo -u nodejs echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/nodejs/grabagadget.log
end script
pre-stop script
rm /var/run/nodejs/grabagadget.pid
sudo -u nodejs echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/nodejs/grabgadget.log
end script
As of Ubuntu 15, upstart is no longer being used, see systemd.

start-stop-daemon error

I am running
sstart-stop-daemon --start --exec
$DAEMON $ARGS
command on Ubuntu and getting the following error
start-stop-daemon: user `p' not found
Can anyone spot the problem?
Abdul Khaliq
You should be using
start-stop-daemon --start --exec "${DAEMON}" -- ${ARGS}
to ensure that start-stop-daemon is not attempting to interpret any of $ARGS but is instead passing all of them directly to $DAEMON.
ephemient is right, but what there must appear is -- before passing arguments. So the not working code above would be like this:
start-stop-daemon --start --exec /etc/init.d/mysql -- -u abc
not unless you can tell us the values of $DAEMON and $ARGS, for starters. It looks like somehow a -u p might be getting passed in.
I can sort of replicate this on my computer by running:
$ start-stop-daemon --start --exec /etc/init.d/mysql -u abc
start-stop-daemon: user `abc' not found
(Success)
(Except that I'm getting a success response as well).