: arguments must be process or job IDs624 - ruby-on-rails

I make a file in my rails app /bin/restart_resque.sh
kill `cat tmp/pids/scheduler.pid`
When I execute bin/restart_resque.sh,I got the error
: arguments must be process or job IDs624
and the process is still working.
Then I change the file to :
kill 2624
I got the same error,but the process 2624 is do exist.why?

You have invalid PID in scheduler.pid or file is not exists.
Check file and permissions:
namei -lm tmp/pids/scheduler.pid
Check PID (resque process must have PID from pid file):
cat tmp/pids/scheduler.pid
ps aux | grep `cat tmp/pids/scheduler.pid`

I found the issue.
when I execute file bin/resque_restart.sh
bin/resque_restart.sh: ASCII text, with CRLF line terminators
so the file format is the reason.but I don't know why.

Related

opensipsctl start gives an error: opensips.pid does not exist

When I run opensipsctl start command for start opensips that time I got one error.
ERROR: PID file /var/run/opensips.pid does not exist -- OpenSIPS start failed
So please help me to solve it.
open up opensipsctl, it includes the file opensipsctlrc, which defined $PID_FILE as /var/run/opensips.pid
Then in opensipsctl, when you run start one of the checks is..
if [ ! -s $PID_FILE ] ; then
echo
merr "PID file $PID_FILE does not exist -- OpenSIPS start failed"
exit 1
fi
Which is saying if then check of whethever '/var/run/opensips.pid exists and is bigger than 0 bytes' fails, then echo out the above error.
This means the file isn't being created.
If you look just above that line it does..
if [ $SYSLOG = 1 ] ; then
$OSIPSBIN -P $PID_FILE $STARTOPTIONS 1>/dev/null 2>/dev/null
else
$OSIPSBIN -P $PID_FILE -E $STARTOPTIONS
fi
Which is where opensips actually starts. I would suggest adding the following to your opensips.cfg if you havn't already..
# Logging
debug=6
log_stderror=no
log_facility=LOG_LOCAL0
..now everything will be logged to /var/log/syslog on boot.
Try boot again, then look at that log for info about what's happened.
Another thing to check, is the user you're running opensips as has permission to access the directory it's trying to create the pid file in.
I had the same error & it was driving me mad as well. I managed to trace it down to one of two things - I had both!
1/ A misconfiguration in the OpenSIPS config file. journalctl -xe should be able to tell you what the error is
2/ Something else is listening on the port that you are trying to listen on
For 2, you can try the below, if you have Ubuntu, to see if anything is already listening on that port
lsof -i :5060
I was able to see logs and fix issue by below steps
Set log_level=4 in opensips.cfg to view debug logs in /var/log/syslog
debug is deprecated in 2.4 and higher version.
You can refer here for different log level

Generated file in Crontab is empty

I need help with this one. An Artisan command is being run by crontab to analyze a logfile and generate a report into an HTML format.
Here is the line of code in the command that is being executed by crontab:
$today = date("d/M/Y");
exec('grep "$today" /path_to_logfile | goaccess -a > /path_of_generated_HTML_file');
exit();
Unfortunately, the file being generated by cron is empty but when you execute the same code directly in the terminal, it successfully generates an html file. I appreciate your help guys.
This is most likely because your PATH is configured incorrectly when running under crontab. For most implementations of crontab, you can simply specify the PATH on the first line on the crontab file opened with crontab -e:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
You could also set the path inside PHP if you so desire:
<?php
putenv('PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin');
$today = date("d/M/Y");
exec('grep "$today" /path_to_logfile | goaccess -a > /path_of_generated_HTML_file');
exit;

Limit of argument size of a command (for ex: in grep "$some_argument_size" filename)

I'm running a shell script and line# 15 is:
grep "$var1$var2" somefilewithonly10000lines_letsay
and getting an error:
line 15: /bin/grep: Argument list too long
What's the limit for the grep command's pattern? -- which when I reach, gives me the above error message.
THe following will tell the limit. Thanks Cyrus.
$ getconf ARG_MAX
More info: http://www.in-ulm.de/~mascheck/various/argmax/

Ruby suppress system true output

I am running a background rake task. (Using '&'). The thing is that I want it to stop sometimes. So I wrote this:
pinger_pid = system "ps | grep rake | awk '{print $1}'"
puts pinger_pid
system "kill -9 #{pinger_pid}"
Seems that I am getting a 'true' output garbage! How can I remove that?
output:
ERROR: garbage process ID "true".
Usage:
kill pid ... Send SIGTERM to every process listed.
kill signal pid ... Send a signal to every process listed.
kill -s signal pid ... Send a signal to every process listed.
kill -l List all signal names.
kill -L List all signal names in a nice table.
kill -l signal Convert between signal numbers and names.
System returns true or false, depending on the success of the command.
Use %x to capture output:
pinger_pid = %x(ps | grep rake | awk '{print $1}')
puts pinger_pid
system 'kill', '-9', pinger_pid

Boot script terminates and gives error (no error logger present)

I made an Erlang application, that shall be started on booting of the operating system. The boot script is stored in /etc/init.d. It looks like this:
#!/bin/sh
cd $ROOT/lib/di
INET_ADDR=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
NODE_NAME=$(echo di#$INET_ADDR)
erl -pa $PWD/ebin -pa $PWD/deps/*/ebin -name $NODE_NAME -boot di $1 -setcookie agfeo
The script tries to determine the IP address of the machine, in order to give the node an unique name. When the machine boots, the script gets executed automatically. On the terminal I get the following output:
(no error logger present) error: "Error in process <0.1.0> with exit value:
{badarg,[{erlang,list_to_atom,[[<<2 bytes>>,<<5 bytes>>,46,98,111,111,116]]},
{init,get_boot,2},{init,do_boot,3}]}"
{"init terminating in do_boot",{badarg,[{erlang,list_to_atom,[[<<2 bytes>>,<<5 bytes>>,46,98,111,111,116]]},
{init,get_boot,2},{init,do_boot,3}]}}
init terminating in do_boot ()
This is what the shell prints out, when the script is loaded automatically.
When I call the script manually, my application gets started normally, without any problems.
Could anybody please explain, what the error message above means?
If we look at the stack trace the last function executed is init:get_boot/2 and the last instruction is erlang:list_to_atom([<<2 bytes>>, <<5 bytes>>, ".boot"]). In the init:get_boot/2 there are three lines with list_to_atom, so error should be one of the following:
'cannot get bootfile';
'bootfile format error';
I believe the error is 'cannot get bootfile'.

Resources