How to use the command 'scancel' (with examples)
- Linux
- November 5, 2023
The scancel
command is used to cancel a Slurm job. It allows users to terminate their jobs in case they are no longer needed or if there are any issues. By canceling a job, the allocated resources can be released and made available for other jobs.
Use case 1: Cancel a job using its ID
Code:
scancel job_id
MOTIVATION: This use case is useful when you want to cancel a specific job using its ID. It could be that the job is taking too long to complete, or you want to prioritize other jobs by canceling this one.
EXPLANATION:
scancel
: The command to cancel a job.job_id
: The ID of the job to be canceled, which can be found by using thesqueue
command.
Example OUTPUT:
scancel 12345
Output:
scancel: Job 12345 has already been terminated
Explanation: The output indicates that the job with ID 12345 has already been terminated.
Use case 2: Cancel all jobs from a user
Code:
scancel user_name
MOTIVATION: This use case is helpful when you want to cancel all the jobs submitted by a specific user. It could be that the user has accidentally submitted multiple jobs or wants to cancel all their jobs due to a specific reason.
EXPLANATION:
scancel
: The command to cancel a job.user_name
: The username of the user whose jobs need to be canceled.
Example OUTPUT:
scancel johndoe
Output:
scancel: Terminated job 12345
scancel: Terminated job 67890
scancel: Terminated job 24680
Explanation: The output shows that all the jobs submitted by the user “johndoe” with the job IDs 12345, 67890, and 24680 have been terminated.
Conclusion:
The scancel
command is a powerful tool to cancel Slurm jobs when they are no longer needed or in case of any issues. By providing the job ID or the user name, specific jobs or all jobs from a user can be canceled. This helps in managing the resources efficiently and allows for better scheduling of jobs.