I try to run a jar file from shell on my qnap nas and tried to use nohup:
nohup java extender.jar &
But i get an error
nohup: no such file or directory
if i run
java extender.jar
it works.
i tried to find nohup
find -name nohup
but the result is empty. It seems to me nohup is not installed. But how can i install nohup? Sorry for this question but i am new to linux.
nohup is not installed on a QNAP NAS!
You can install it:
Install ipkg from Webinterface Application Manager (QPKG)
Login via ssh and run:
ipkg update
ipkg list | grep coreutils
ipkg install coreutils
Thats all!
Related
I have multiple app apks downloaded into my laptop. I want to use java to write a script, so that all apks can be installed to my device automatically. Anybody can help me out with this?
Thanks!
if you are Using Linux
#!/bin/sh
for file in /dir/*
do
adb install $file
done
you can install using adb like
adb install application1.apk & adb install application2.apk & adb install applicaiton3
you can install using
for %f in (D:\Directory\*.apk) do adb install "%f"
using MAC
for file in apk/*;
do
./adb install $file;
done
and a final solution using batch file created By Osman Vielma
#echo Preparing to install all .apk files in "C:\Directory\" folder to device
#pause
#for /f "delims=|" %%f in ('dir /b "C:\Directory\"*.apk') do #"C:\Directory_ADB\ADB\adb.exe" install -r "C:\Directory\%%f"
#echo End of Batch File
#pause
I am using ubuntu 14.04
I am running a jar file which should be collection a large amount of data for a few days.
I am running the jar file thought this command and it works fine.
java -jar xxx.jar
However when i close the putty, the process stopped. Is there a way for a jar file to run even when i close the putty?
You can use nohup to run the jar(any process) in background.
Use the following command in the putty session :
nohup java -jar xxx.jar &
You need the nohup command. This command makes processes keep running despite closing terminal.
Run your jar with (in case you are in the right folder):
nohup java -jar xxx.jar &
I would suggest to you use
nohup java -jar xxx.jar > /dev/null 2>&1 &
which redirects standard error & output of the command to /dev/null which means it's discarded. If you need the console output of this command then you can redirect it to any file as follows
nohup java -jar xxx.jar > output.log 2>&1 &
I have a .jar file I want to run whenever the system reboots/starts, so I put the line
nohup java -jar /mnt/fioa/fusion/nfs/labStats/LabInfoAutoLog.jar > /dev/null &
in my /etc/rc.local file. The program is validated as working, and if I run the above command at the command line the program works as expected.
Other versions I have tried without success:
nohup /usr/bin/java -jar /mnt/fioa/fusion/nfs/labStats/LabInfoAutoLog.jar > /dev/null &
and:
nohup java -jar /mnt/fioa/fusion/nfs/labStats/LabInfoAutoLog.jar 2> /dev/null \ .. &
I am running centos 6.4.
Check that your jar file is accesible roots, NFS mounted volumes may impose special restrictions for root.
Instead of discarding your error messages, you might want to route them to syslog, something like 2> /sbin/logger -t FOO 1> /sbin/logger -t BAR
Maybe the path isn't set yet at startup time and you need the full path to the java executable or, possibly, nohup.
I'm trying to run chimpchat from Java code and I get this error:
Unexpected exception 'Cannot run program
"/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools": error=13,
Permission denied' while attempting to get adb version from
'/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools
I can run adb from the shell as a normal user. I've chmod 777'ed the adb program.
What can I do? I run Linux Mint 14 (64bit) (have ia32-libs installed) and use java7-openjdk-amd64.
When I tried to open the Android SDK from Eclipse I also received the error
"...Permission denied' while attempting to get adb version from '..."
initially, I tried
sudo apt-get install ia32-libs
but it did not fix the problem. i had them already.
What fixed the problem was
sudo chmod -R 777 /name-of-root-directory-containing-SDK
Recommendation! Place SDK, JDK and all other manually installed non-system resources in their own root directory.
[ example: /resource ]
Permissions set on this directory make no change to any critical files.
Warning!
Erroneous use of chmod -R on system directories can lead to "must reinstall OS from scratch"
it then complains about not finding the adb program
you need to install ia32-libs package:
sudo apt-get install ia32-libs
The error is specifying the directory that contains adb, rather than the adb executable itself. Check the permissions on the directory, and that your program is attempting to run the proper command (it may be trying to run the directory, which clearly won't work...).
I am using the Jetty/Solr build that comes with Solr and would like to run it in the background instead of in the terminal.
Right now I start it by java -jar start.jar but I would like it to log to a file and run in the background on the server so that I can close the terminal window.
I'm sure there is some java config that I can't find.
I have tried java -jar start.jar > log.txt & but no luck still outputs to the terminal window.
Thanks.
Try something like:
nohup yourcommand > output.log 2>&1 &
nohup will prevent yourcommand from being terminated in the event you log out.
& will run it in the background.
> output.log will send stdout to output.log
2>&1 will redirect stderr to stdout
nohup is used to execute commands that runs after logout from a shell. What you need here is '2>&1'. This redirects standart error to the standart output. So everything will be logged to log.txt.
Try this
java -jar start.jar > log.txt 2>&1
Also you can add an '&' start it as a background process.
You can run it with screen if you are on unix.
You can properly install it as a linux service too.
cd to your jetty folder, for example mine is:
cd /home/spydon/jetty/
They have actually made most of the work with the jetty.sh file, so copy that one to /etc/init.d/
sudo cp ./bin/jetty.sh /etc/init.d/jetty
Then open the file with your favorite text editor, like vim or nano
sudo vim /etc/init.d/jetty
In the beginning simply uncomment (remove the hash(#)) three lines that says something like:
#chkconfig: 3 99 99
#description: Jetty 9 webserver
#processname: jetty
Meanwhile you have the text editor open, also add the jetty home directory to the beginning of the file, mine now looks like this:
#!/usr/bin/env bash
#
# Startup script for jetty under *nix systems (it works under NT/cygwin too).
JETTY_HOME=/home/spydon/jetty
# To get the service to restart correctly on reboot, uncomment below (3 lines):
# ========================
chkconfig: 3 99 99
description: Jetty 9 webserver
processname: jetty
# ========================
Now you should be able to start it with
sudo /etc/init.d/jetty start
And if you want it to run every time you reboot, simply add
sudo ln -s /etc/init.d/jetty /etc/rc1.d/K99jetty
sudo ln -s /etc/init.d/jetty /etc/rc2.d/S99jetty
This should work for most modern distros, but I've only tried it on debian based ones.
You could also consider doing a symlink to the jetty.sh so it will be easier to upgrade.
You may want to try nohup, as explained in this previous answer.