Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What commands can I use in Terminal to see pending or scheduled tasks for today or tomorrow.

For example how can I detect pending system shutdown?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

There is util called cron. Usually cron handle task scheduling in Linux. But there is also few another ways to do it.

In case of cron, you can just run crontab -l to see all task scheduled by current user.

If you want to check task for another user use -u $username key

TO check root user tasks: sudo crontab -u root -l

To understand crontab format please read wiki

If you want to detect exactly system shutdown

The one of possible solutions is to wrap shutdown command in a script.

Another solution is to write a trap detecting SIGTERM signal, but this solution do not give you time when system will start halting. Read about trap here

Also there is another one tricky solution:

If you run sudo shutdown -r 20:00, you spawn a process that will start shutdown at 20:00.

You can find this process using ps

$ ps -ef | grep shutdown
root     32222 32032  0 15:55 pts/8    00:00:00 sudo shutdown -r 20:00
root     32223 32222  0 15:55 pts/8    00:00:00 shutdown -r 20:00
c0rp     32382 32233  0 15:55 pts/10   00:00:00 grep --color=auto shutdown

And you can see a time here. If you kill this process, shutdown will be canceled

share|improve this answer
    
thanks for the link to wiki documentation its helpful but for example I just run sudo shutdown -r 20:00 for example and when I run any of your suggested commands it says no crontab for root so my question is how can I list command like that in case I forgot about that it was supposed to restart at 20:00 or any other hour. –  JohnnyEnglish Apr 5 at 9:35
    
Thank you! ps works just great :-) –  JohnnyEnglish Apr 5 at 10:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.