I've read about
ionice to control the scheduling priority of running processes. However, I still don't understand when and how are they useful for. For instance doing something like:
nice -n 13 pico myfile.txt
With regards to pico it's unlikely to ever be much cause for concern so it's not the kind of command you would normally nice/renice or ionice. However your command would execute pico niced to +13. Which would mean it would get significantly less time allocated to it. For example, following on from your pico line. Normally pico executed looks like this:
Where NI is the nice level. If I run pico with your command it looks like this:
OK so that demonstrates the command line you run is effective, but what does it actually do? OK let's say you have a system that is quite busy but not obscenely so. It's pretty busy all around the clock, at midnight an essential maintenance task starts. It's mysql command line running a script to generate some daily stats. There's a lot of processing so it hits the CPU hard and the users complain about this. Vehemently, as they do. What can you do about it? It's not essential how long this script takes so you prepend 'nice -n 13' to the command and the next time it runs it doesn't affect the users so bad but takes a bit longer to complete. The owner of the MySQL script doesn't care as he only wants the stats when he gets in the next day. Everyone is happy.
Stories aside these tools can let you exert some control over how the system prioritises the CPU (possibly IO in the case of ionice) time allocated to tasks. They will only have an effect when the system is loaded, before that everyone tasks are being allocated all the time they need.
The renice command works in a very similar way but it allows you to alter the priority of processes that are already running. So in the above anecdote you could use renice to alter the priority of the mysql command without restarting it. The following command would renice all running tasks named 'mysql' to +13, a much lower priority:
As for ionice I cannot comment but would guess it lets you do similar things with IO. Influencing how much io certain tasks get to perform, e.g. disk read/writes. Could be useful in throttling backup process if necessary?