Page tree
Skip to end of metadata
Go to start of metadata


When submitting a job with sbatch, it produces an error:

sbatch: error: Batch script contains DOS line breaks (\r\n)
sbatch: error: instead of expected UNIX line breaks (\n)

This is due to a text editor encoding your SLURM batch script using DOS-style line breaks. This often occurs when creating or editing a script on a Windows system. DOS line breaks consist of two separate characters: a carriage return character (often notated as \r) and a new line feed character (as \n) which can be seen in the error message. This style of line break is incompatible with SLURM and you will need to modify your script before it will run with sbatch.


SLURM expects UNIX-style line breaks which only have a single line feed character (\n) and no carriage return characters - deleting the carriage returns will resolve the issue. The most immediate remedy is using the in-built dos2unix utility, available on the login nodes. The default behaviour of the utility is to overwrite the existing file as it makes the necessary changes. Example use:


To prevent the issue from reoccurring, a different approach to editing your scripts is required. We recommend using the text editors available on the clusters, which use UNIX line breaks by default; or using Notepad++ (external link) if you prefer to script on Windows, which has features to save files using UNIX line breaks if required.