Все работает нормально:
#!/bin/sh
# This script will do exactly the same job of Ctrl^C for background process
# find the PID of running script
pid=$(ps -ef| grep <scriptname>)
echo ".... PSR Stats collection script PID:"+$pid +"is getting exited abruptly"
# exit the process
kill -INT $pid
Вам необходимо выполнить команды apt
от имени пользователя root. Или используйте sudo apt
.