You are here

run.net.sh won't work in cron

16 posts / 0 new
Last post
moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks
run.net.sh won't work in cron

I can manually run script run.net.sh but script won't work in cron.
I got "DotNet required, but it's not installed" error.
Any idea how to fix this?
Maybe to put absolute path to dotnet in run sh.script?

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

just run webgrab manually in crond.
/path/to/dotnet/dotnet /path/to webgrab.dll path/to/webgrab/config/folder
example(i installed dotnet in opt folder)
/opt/dotnet/dotnet /home[username]/.wg++/bin.net/WebGrab+Plus.dll /home/[username]/.wg++

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

After that I have this error:
* You intended to execute a .NET program:
The application '/mnt/usb/webgrab/.wg++/run.net.sh' does not exist.
* You intended to execute a .NET SDK command:
It was not possible to find any installed .NET SDKs

My dotnet --info:

Host (useful for support):
Version: 5.0.17
Commit: 6a98414363

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.NETCore.App 5.0.17 [/root/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

what user are you running your crond as,maybe try running it as root user.
also how did u install dotnet?
manually or via your package manager?

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

i did a few tests and i think u installed dotnet manually.
when u do this u must add dotnet to your $PATH variable,see the dotnet install docs.

create a new sh script(dotnet.sh for example) and put this inside,edit the paths to your dotnet,webgrab dll and config folder.
on my nas i use custom paths for everything,its how i run it.

#!/bin/sh

export DOTNET_ROOT=/opt/dotnet
export PATH=$PATH:$DOTNET_ROOT

dotnet /raiddata/0/NAS_WebGrab/dotnet/WebGrab+Plus.dll /raiddata/0/NAS_WebGrab

exit

run this sh file in crond.

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

I was installing dotnet manually.

I was trynig your script but I still have error:
* You intended to execute a .NET program:
The application '/mnt/usb/webgrab/.wg++/run.net.sh' does not exist.
* You intended to execute a .NET SDK command:
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
https://aka.ms/dotnet-download

Do I need to install .NET SDK?

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

nope.just the runtime is all you need which u have installed.
the DOTNET_ROOT path above is the path to the dotnet folder only not the path to the dotnet binary itself.

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

also in terminal if you enter these lines(one at a time,make sure your path to your dotnet folder is correct)

export DOTNET_ROOT=/opt/dotnet
export PATH=$PATH:$DOTNET_ROOT

then
echo $PATH

you should see the path to your dotnet folder listed.

which dotnet

this should return the same path

run.net.sh should work now as it uses the which command to check it dotnet is installed.

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

I got this:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/dotnet:/root/dotnet/dotnet

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

/root/dotnet
this is the correct path

/root/dotnet/dotnet
this is the path to the binary itself which is incorrect

you can fix this manually,i dont know where your $PATH variable is stored(it depends on what linux distro you use)

for ubuntu its /etc/environment
edit this file and remove the /root/dotnet/dotnet path
i dont know how linux knowledged you are put the paths are separated by a :
you should be able to figure it out how to fix it.

it should look like this
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/dotnet

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

If I type which dotnet command then I got this path:
/root/dotnet/dotnet

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

thats correct
did u try running run.net.sh in crond again?

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

Yes but without success.

Blackbear199
Offline
Blackbear199's picture
WG++ Team memberDonator
Joined: 9 years
Last seen: 40 min

edit your run.net.sh file and before the which dotnet command add

export DOTNET_ROOT=/root/dotnet
export PATH=$PATH:$DOTNET_ROOT

are u running your crond as root or a user(i already asked this)
since dotnet is installed in /root users may not have permission to access this

in your crond try
* * * * * root /path/to/run.net.sh
edit the * * * * * to whatever u want

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

I run crond with root user

moj.rapidshare
Offline
Donator
Joined: 4 years
Last seen: 4 weeks

I think that is the solution:

**********
edit your run.net.sh file and before the which dotnet command add

export DOTNET_ROOT=/root/dotnet
export PATH=$PATH:$DOTNET_ROOT
**********

Now cron job is working ok.

Thank you for helping me to resolve this problem.

Log in or register to post comments

Brought to you by Jan van Straaten

Program Development - Jan van Straaten ------- Web design - Francis De Paemeleere
Supported by: servercare.nl