LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 08-09-2023, 03:07 PM   #1
gonencing
LQ Newbie
 
Registered: Aug 2023
Posts: 2

Rep: Reputation: 0
when i use nice with a long command it isn't working


Hi,

sudo nice -n -18 $(okular Documents/x/x.pdf 2> log.file &)

when i use this command it doesnt asks me for a sudo password, as it is not opening the pdf, then when i try to close terminal, it shows that password input but closes rapidly. so it failes. i couldn't figure out why.

my os is ubuntu 22.04
 
Old 08-10-2023, 08:38 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,748
Blog Entries: 4

Rep: Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970
Welcome.

It's because of the ampersand's placement in the sequence, as well as the command substution, but rather than address that, there is a clarifying question to be answered: What are you trying to do? There is 100% a different way to do it, since Okular should not be run as root.
 
Old 08-11-2023, 05:59 PM   #3
gonencing
LQ Newbie
 
Registered: Aug 2023
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
Welcome.

It's because of the ampersand's placement in the sequence, as well as the command substution, but rather than address that, there is a clarifying question to be answered: What are you trying to do? There is 100% a different way to do it, since Okular should not be run as root.

I want to read X.pdf with okular, while the code and process is on background -so it doesn't distract my terminal-, and with a faster way-i think its becoming faster as the nice is lower- .
 
Old 08-11-2023, 07:20 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,748
Blog Entries: 4

Rep: Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970Reputation: 3970
Then sudo is not needed as you wish to lower the priority not raise it.

Code:
nice -n 18 okular Documents/x/x.pdf 2> log.file &
Reread "man nice" and "man 2 nice". The higher the number, the lower the priority.
 
Old 08-12-2023, 02:44 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,250

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
yes, see man page of nice. You do not need to use sudo if you want to lower the priority, but actually you tried to increase it, which requires root user.
Anyway using nice is completely useless in your case, it won't make your terminal any faster.
Running okular in the background (using &) will detach it from the terminal (and operate independently).

Additionally your original syntax is just wrong, you must not use $( ), that's why it's acting so weird.
 
Old 08-12-2023, 12:46 PM   #6
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 872
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Quote:
Originally Posted by gonencing View Post
Hi,
sudo nice -n -18 $(okular Documents/x/x.pdf 2> log.file &)
I am curious which "nice" would be used in this case. I expect you are using the bash builtin nice. Can you try "/bin/nice" instead of just "nice" ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Wrapping a long command with \ on the CLI isn't working JockVSJock Linux - Newbie 15 02-09-2016 01:42 PM
Why nice value isn't working kernel99 Red Hat 2 05-09-2013 04:19 PM
Aboout "with very long lines",how long is very long? yun1st Linux - Newbie 4 07-20-2012 03:38 PM
long long long: Too long for GCC Kenny_Strawn Programming 5 09-18-2010 01:14 AM
Nice and confused about nice Hangdog42 Linux - General 5 06-03-2003 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration