When I run the following command in cygwin,
$ cygrunsrv -I cron -p C:\cygwin64\bin --args -n
I get the following error
cygrunsrv: Given path doesn't point to a valid executable
Why am I getting this error?
You only gave a folder and not a path to the executable. Besides this I wouldn't recommend to use windows paths in cygwin, this can cause errors. You should write /cygdrive/c/cygwin64/bin/something instead of C:\cygwin64\bin\something.exe
Perhaps you are looking for an
installation guide, and you would like to do something like this:
Install cron as a windows service, using cygrunsrv:
cygrunsrv -I cron -p /usr/sbin/cron -a -D
net start cron
Related
I have already solved this problem but I do not know why this solves the problem and I don't like not knowing what went wrong. I'm using the terminal on Ubuntu
Here was the issue...
If I run $ ngm -args it runs but fails because it requires sudo
If I run $ sudo ngm -args I get the error like ngm not found
If I run $ sudo /usr/local/lib/ngm -args it runs with sudo and works perfectly.
I don't understand why the 3 works and 2 doesn't work.
When trying to run $ ngm -args, the shell will look for the executable in it's $PATH variable, and it finds it. When trying to run the executable it finds that it has to be sudo and exits.
When you run $ sudo ngm -args, the shell will look for the executable in the $PATH environment of the Root user, and it can't find it.
When running it like the last option, the shell doesn't need to look in the $PATH of the root user, because it finds it in the path that you specified /usr/local/lib/ngm, so both issues are gone.
This might be a starting point in order to understand the PATH
So I'm trying to run a wget command using crontab every 5 minutes. My problem that I have is it's just not running. I did crontab -l to see what was running, the command is there.
the command is: wget --output-document="/Users/proudowner/Desktop/tfgo/bp.json" http://backpack.tf/api/IGetMarketPrices/v1/?key=<key>
And the error log says: /bin/sh: wget: command not found
The command also runs fine without crontab.
In crontab -e, make this your first line:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Then wget should work without specifying the full path.
You can also just specify the full path to wget (which wget to find it):
/usr/bin/wget --output-document="/Users/proudowner/Desktop/tfgo/bp.json" http://backpack.tf/api/IGetMarketPrices/v1/?key=55085a94ba8d88d1538b4576
I am creating a script meant to be run as superuser that reads a file and runs a number of scripts on behalf of all users. The important bit is this:
sudo -u $user -H source /home/$user/list_of_commands
However, whether I encose the command with quotesor not, this fails with:
sudo: source /home/user/list_of_commands: command not found
I have even tried with the . bash builtin:
sudo: . /home/user/list_of_commands: command not found
Of course running source outside a sudo environment works. I thought there might be a PATH problem, and I tried to bypass it by providing the full path to source. However, I cannot find the executable: which source returns which: no source in (/usr/local/sbin:usr/local/bin:usr/bin). So I'm stuck.
How do I make a script source a file as a user?
source is a builtin not a command, use it with bash -c:
sudo -u $user -H bash -c "source /home/$user/list_of_commands"
I am trying to make cgMiner auto-start when my Raspberry Pi (Raspbian Linux) starts.
Edited the rc.local file:
sudo nano /etc/rc.local
and added this line:
nohup ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 -S /dev/ttyUSB1 >/dev/null 2>&1&
and cgMiner doesn't start. If I type in terminal the exact same line with sudo in front it works perfectly.
sudo nohup ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 -S /dev/ttyUSB1 >/dev/null 2>&1&
What can I do?
I think it is related to the path or better the current working directory.
You are using ./cgminer and not a full path. So either use the full path or first cd to the directory containing the cgminer program.
Also have a look at the following page over at adafruit doing the exact same thing you are trying to accomplish
http://learn.adafruit.com/piminer-raspberry-pi-bitcoin-miner/configure-auto-start
Adafruit has the following code in /etc/rc.local
cd /home/pi/PiMiner
python PiMiner.py &
cd ..
nohup ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 -S /dev/ttyUSB1 >/dev/null 2>&1&
The first and third line (the cd commands) ensure that the folder containing the folder containing the cgminer command is the current directory.
From the two cd commands adding the following command before the line containing the cgminer command would solve your issue
cd /home/pi
I seem to have found the solution for this problem, assuming it is the same as for bfgminer.
After spending a full day playing with init.d scripts, I found the simplest way is to make sure your cgminier.conf file has all the arguments in then add the following to the end of /etc/rc.local
cd /home/YOURNAME/bfgminer
sudo ./bfgminer
It ran without the sudo part, but didn't start up my block erupter without it.
I also managed to get it running from init.d, but had issues with it preventing system rebooting when done that way.
Hope that helps
I configured cygwin in Windows Server 2008, now we need to implement automation
I am writing a batch script to add user to cygwin\etc\passwd file using following command
mkpasswd -l -u %username% -p /home >> /etc/passwd
Please help me how to execute following cmd in batch file
echo off
C:
chdir C:\cygwin\bin
bash --login -i
mkpasswd -l -u %username% -p /home >> /etc/passwd
It's not working
You're mixing Windows and Unix in your windows batch file. The batch file is running as a Windows command, as is the mkpasswd command in it. Windows has no concept of /etc/passwd and will throw an error. Probably something like;
D:\cygwin\bin>mkpasswd -l -u testusr -p /home >> /etc/passwd
The system cannot find the path specified.
Given what you want to do with mkpasswd I'd suggest you find a way to run your automation from within Cygwin. Perhaps setting up a cron job.