I want to limit the processing capability to only a single core in my machine, so I found out taskset
can help to set a single core, say core 0, as the following (Courtesy to this answer):
taskset -c 0 -p 45678
The problem is that how can I determine the process_id pid here when my program is not running yet? Do we just set an arbitrary process id to be picked up by Linux, in this case 45678
? If it is so, is it possible to do that in a shell script as the following:
#!/bin/sh
# Set the processing unit
taskset -c 0 -p 45678
# run python script
python main.py