I'm trying to start up kdb with multiple processes to use to write scripts with KDB developer.
I understand that the processes that are set up need to be done so outside of the master process.
I have attempted to do this with a function in my .bashrc that creates 7 instances which are expecting a maximum of 8 processes. I then start up a final process with developer.
When I do this and try to connect, my OS informs developer that the connections are refused.
Could you advise on the correct way to start 8 processes to use with IPC in KDB?
This is my multiple process startup function in .bashrc:
mq() {
echo "Spawning 7 q processes";
q -s -8 -p 20001;
q -s -8 -p 20002;
q -s -8 -p 20003;
q -s -8 -p 20004;
q -s -8 -p 20005;
q -s -8 -p 20006;
q -s -8 -p 20007;
}
This is the code in .bashrc to start developer:
# Assumes user name is claude and opens Q with 8 threads. (to build separate processes use a negative number)
alias q='rlwrap -r q -s -8'
# Developer set to open with 8 threads. (to build separate processes use a negative number)
alias developer='source /pathToDir/developer/config/config.profile; rlwrap -r q /pathToDir/developer/launcher.q_'
To start all this up, I open one terminal and type mq then open another terminal and type developer
Once in developer, I assign a handle to each process like this:
{hopen("::",string[20000+x])}each 1+til 7
Then the system tells me that the connection is refused.
How should I do this?
Thanks and regards,
I think you should use & when start multiple q processes in your shell script:
mq() {
echo "Spawning 7 q processes";
q -s -8 -p 20001 &
q -s -8 -p 20002 &
q -s -8 -p 20003 &
q -s -8 -p 20004 &
q -s -8 -p 20005 &
q -s -8 -p 20006 &
q -s -8 -p 20007 &
}
mq
Without &, only 1 process will be open at one time.
It work for me:
./mq.sh
bchen#homer:~$ ./mq.sh
Spawning 7 q processes
q)q)q)q)q)q)
In q session:
q){hopen("::",string[20000+x])}each 1+til 7
4 5 6 7 8 9 10i
To connect to q process, hopen should be used.
In a q session:
q){hopen("::",string[20000+x])}each 1+til 7
6 7 8 9 10 11 12i
It returns handles for each process.
We could make use of these handles to send commands for each process.
Related
There is no process named abc. I am pretty new to Sensu, please help is needed. The same check when executed on my sensu-client directly gives the following result:
root#pune-4755-col-stag-1:~# sudo check-process.rb -p /abc/ -W 1
CheckProcess CRITICAL: Found 0 matching processes; cmd //abc//
root#pune-4755-col-stag-1:~# sudo check-process.rb -p abc -W 1
CheckProcess CRITICAL: Found 0 matching processes; cmd /abc/
I am able to run Weka form CLI using below command:
java -cp weka.jar weka.classifiers.functions.MultilayerPerceptron -t Dataset.arff
Weka Explorer Target Selection Parameters
How can I set the Target Parameters for example "Number of time units for forecast" using command Line?
We are trying to use command line to improve memory utilization , we have a large dataset with 10000 attributes which is causing Java Heap Space everytime we run it from GUI.
Thanks For the response.
Posting answer to my own question:
java -cp weka.jar weka.Run weka.classifiers.timeseries.WekaForecaster -W "weka.classifiers.functions.MultilayerPerceptron -L 0.01 -M 0.2 -N 5000 -V 0 -S 0 -E 20 -H 20 " -t <dataset file> -F <FieldList> -L 1 -M 3 -prime 3 -horizon 6
We can always get more help using :
java -cp weka.jar weka.Run -h
I am trying to find a way to run a script on sleep before an x session ends, because the script requires an active x session to execute properly. Storing the script in /etc/pm/sleep.d did not work (and returned errors related to a non-existent x session). Any ideas where to put the script?
Update in response to comments
king#death-star /etc/acpi $ cat 01_revert_kb_on_sleep
#!/bin/bash
touch ~/Desktop/touchfile_my_script_acpi
case "$1" in
hibernate|suspend)
sh -c "/home/king/Desktop/Scripts/rotate_desktop normal; /home/king/Desktop/Scripts/misc/my_keyboard on" 2> ~/Desktop/revert_kb_error_log.txt ;;
#thaw|resume)
king#death-star /etc/acpi $ ls
total 1MB
drwxr-xr-x 3 root root 1MB Jun 11 23:36 .
drwxr-xr-x 163 root root 1MB Jun 11 23:41 ..
-rwxr-xr-x 1 root root 1MB Jun 11 23:36 01_revert_kb_on_sleep
king#death-star /etc/acpi $ ps -ef| grep acpid
root 1070 1 0 23:41 ? 00:00:00 acpid -c /etc/acpi/events -s /var/run/acpid.socket
king 3499 2574 0 23:52 pts/2 00:00:00 grep --colour=auto acpid
Step 1.
a. Enable and start the acpi service.
b. Run the acpi_listen command and try putting the computer to sleep via various methods (pushing the power button, closing the lid, etc.)
c. Find out what events are triggered, when you do the above. In my case they were: button/lid LID close and button/sleep SBTN 00000080 00000000
Step 2.
a. Create the file /etc/acpi/events/my_events with the following:
event=(button/sleep SBTN|button/lid LID close)
action=/etc/acpi/my_script.sh
Substitute the events in the event= line with your events.
b. Create the file /etc/acpi/my_script.sh with the following:
#!/bin/sh
/home/king/Desktop/Scripts/rotate_desktop normal
/home/king/Desktop/Scripts/misc/my_keyboard on
NB. You might need to add export DISPLAY=:0 before the scripts to get access to your X session.
NB2: Your scripts will run with root user credentials. To run with your user credentials, you might want to do:
sudo -u king /home/king/Desktop/Scripts/rotate_desktop normal
sudo -u king /home/king/Desktop/Scripts/misc/my_keyboard on
c. Make the file /etc/acpi/my_script.sh executable:
chmod +x /etc/acpi/my_script.sh
d. Restart the acpi service.
Step 3. Share and enjoy.
I have an upstart init script, but my dev/testing/production have different numbers of cpus/cores. I'd like to compute the number of worker processes to be 4 * number of cores within the init script
The upstart docs say that the script stanzas use /bin/sh syntax.
I created /bin/sh script to see what was going on. I'm getting drastically different results than my upstart script.
script stanza from my upstart script:
script
# get the number of cores
CORES=`lscpu | grep -v '#' | wc -l`
# set the number of worker processes to 4 * num cores
WORKERS=$(($CORES * 4))
echo exec gunicorn -b localhost:8000 --workers $WORKERS tutalk_site.wsgi > tmp/gunicorn.txt
end script
which outputs:
exec gunicorn -b localhost:8000 --workers 76 tutalk_site.wsgi
my equivalent /bin/sh script
#!/bin/sh
CORES=`lscpu -p | grep -v '#' | wc -l`
WORKERS=$(($CORES * 4))
echo exec gunicorn -b localhost:8000 --workers $WORKERS tutalk_site.wsgi
which outputs:
exec gunicorn -b localhost:8000 --workers 8 tutalk_site.wsgi
I'm hoping this is a rather simple problem and a few other pairs of eyes will locate the issue.
Any help would be appreciated.
I suppose I should have answered this several days ago. I first attempted using environment variables instead but didn't have any luck.
I solved the issue by replacing the computation with a python one-liner
WORKERS=$(python -c "import os; print os.sysconf('SC_NPROCESSORS_ONLN') * 2")
and that worked out just fine.
still curious why my bourne-shell script came up with the correct value while the upstart script, whose docs say use bourne-shell syntax didn't
I would like to connect to a VPN on start-up of OSMC.
Environment:
installed OSMC on Raspberry 2
downloaded, compiled and installed shrew soft vpn on the device
As user 'osmc' with ssh
> sudo iked starts the daemon successfully
> ikec -r "test.vpn" -a starts the client, loads the config and connects successfully
rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo iked >> /home/osmc/iked.log 2>> /home/osmc/iked.error.log &
ikec -a -r "test.vpn" >> /home/osmc/ikec.log 2>> /home/osmc/ikec.error.log &
exit 0
after start of raspberry iked is as process visible with ps -e
but ikec is not running
osmc#osmc:~$ /etc/rc.local starts the script and connects to vpn successfully
Problem:
Why does the script not working correctly on start-up?
Thank you for your help!
I was also looking to do the same thing as you and ran into the same problem. I'm no linux expert, but I did figure out a workaround.
I created a script called ikec_after_reboot.sh and it looks like this...
$ cat ikec_after_reboot.sh
#!/bin/bash
echo "Starting ikec"
ikec -r test.vpn -a
I then installed cron.
sudo apt-get update
sudo apt-get install cron
Edit the cron job as root and run the ikec script 60 seconds after reboot.
sudo crontab -e
SHELL=/bin/bash
#reboot sleep 60 && /home/osmc/ikec_after_reboot.sh & >> /home/osmc/ikec.log 2>&1
Now edit your /etc/rc.local file and add the following.
sudo iked >> //home/osmc/iked.log 2>> /home/osmc/iked.error.log &
exit 0
Hopefully, this is helpful to you.