Nohup Error No Such File or Directory

nohup error no such file or directory

The usual problem with scripts that run from the command line and not when run by cron is 'environment'. There are many questions on SO where this is exemplified, including:

  • Perl script works but not when via cron
  • Why does my command line not run from cron?
  • Bash script not executing in cron correctly
  • How can I set environment variables that crontab will use?

For debugging purposes, add a command/line to the cron-run script that does:

env > /tmp/cron.job

Review whether the PATH there includes what you expect, and in particular, whether it includes the directory (directories) where each of the three programs is installed. And do check that you run the programs you expect from the command line:

which vmpstat mpstat iostat

It is a reasonable guess that the two 'missing' commands are not in a directory on PATH when your script is run by cron. And cron gives you a bare minimal environment; it is completely unlike at in that respect.

See also:

  • Crontab and testing a command to be executed
  • How do I add pre-hook and post-hook scripts that run before all of my cron jobs?

No such file or directory error when I try to run a Linux script written from Windows system

The below line in your output indicates you're having dos line-endings "CR - Carriage returns" in your file.

with CRLF line terminators

Try running cat -v your_file , if it shows ^M at the end of each line you'd need to run dos2unix on them, eg dos2unix your_file to convert them to unix format

Running a JMeter script with nohup giving No such file or directory

I'm not fully getting what you're trying to achieve, the correct equivalent of your command would be something like:

nohup bash -c "JVM_ARGS=\"-Xms1024m -Xmx2048m\" && export JVM_ARGS && ./jmeter -n -t /home/performance/LoadTesting/Portal-8HR.jmx -R 192.168.2.32:1099 -GTest_Name=LongDurationLoadTest -GTest_Triggered_By=LoadExecuter -Gtest_Id=200Con_8HR_Test01 & ./jmeter -n -t /home/performance/LoadTesting/Portal-8HR.jmx -R 192.168.2.32:1099 -GTest_Name=LongDurationLoadTest -GTest_Triggered_By=LoadExecuter -Gtest_Id=200Con_8HR_Test01 & ./jmeter -n -t /home/performance/LoadTesting/Portal-8HR.jmx -R 192.168.2.32:1099 -GTest_Name=LongDurationLoadTest -GTest_Triggered_By=LoadExecuter -Gtest_Id=200Con_8HR_Test01" 2>&1 &

If the only concern is network connectivity loss between putty, whatever it is, and Linux Azure VM you could use a terminal multiplexer like screen or tmux on the Azure VM side so you can attach to the running session when needed from this or another machine.

There are also a lot of ways to schedule a Linux job starting from simplest cron definitions, systemd timers or you can use a "heavy artillery" like Jenkins which allows flexible scheduling and kicking off jobs on other triggers. If you go for Jenkins you can enjoy the benefits of the Performance Plugin allowing marking builds as failed or unstable depending on test metrics received and plotting performance trend charts

Shell node: No such file or directory

I would like to thank @Florian Schlag for helping me reach the answer and giving me the correct answer. I have pasted my file below for reference. Please note that I had to change some files around but these can be deduced from output npm errors.

#!/bin/bash
PATH=$PATH:/home/<user>/bin/
NPM="`which npm`"

if [ "x" == "x$NPM" ]; then
(>&2 echo "NPM not installed")
exit 1
fi

pID=$(pgrep "PM2" -f)

if [ -n "${pID}" ];
then
exit 0
else
# start it
echo "restarting"
nohup $NPM start ./<file path ton script> --production &
fi


Related Topics



Leave a reply



Submit