Umair Ayub
Umair Ayub

Reputation: 21321

/dev/null: Permission denied - run script in background but do not ouput logs

I want to run a script in background after being disconnected to SSH.

I am running this command

nohup python batchscript.py ?& /dev/null &

But it gives me -bash: /dev/null: Permission denied error.

I searched online and found these kind of solutions

rm -f /dev/null; mknod -m 666 /dev/null c 1 3

I did that ... and ran my script again, I got same error

Also I am getting that nohup.out file being created, I dont want that.

My ultimate goal: I want to run script even I am disconnected and most importantly I dont want it to output anything into any file, because log file will be huge.

Upvotes: 1

Views: 3482

Answers (2)

Jamil Said
Jamil Said

Reputation: 2093

Try the code below:

nohup python batchscript.py >/dev/null 2>&1 &

That would redirect both stderr and stdout to null, thus there would be no nohup.out being created or no information appended anywhere.

Upvotes: 0

Ed Heal
Ed Heal

Reputation: 60027

I think you need to pipe stdout to /dev/null along with stderr

Try

nohup python batchscript.py > /dev/null 2>&1 &

Upvotes: 2

Related Questions