According to latexmk's documentation, cleanup operations override any compilation operations
-c - clean up (remove) all nonessential files, except
dvi, ps and pdf files.
This and the other clean-ups are instead of a regular make.
Try running latexmk -c in a separate step.
latexmk -pdf test.tex # Generate the pdf...
latexmk -c # ... and then clean aux files
By the way, I would not recommend always cleaning up after building the latex files. The point of using latexmk is to avoid redundant recompilation passes and that is only possible if you preserve your auxiliary files between compilations. If you insist in cleaning up, then it might be simpler to ditch latexmk and just use a simple shell script that calls pdflatex 3 times and then removes the auxiliary files.
#! /bin/sh
lflags='-interaction=batchmode'
pdflatex -draftmode $lflags test
bibtex test
pdflatex -draftmode $lflags test
pdflatex $lflags test
rm -f *.aux *.bbl *.blg *.brf *.dvi \
*.fls *.log *.out *.pdf *.ps *.toc
~
Latexmkautomates getting the number of runs correct. – John Collins Apr 17 '15 at 13:54latexmk -pdf test.texgoes through the required number of passes all at once and thenlatexmk -cclears all theauxfiles orlatexmk -cis called after each pass oflatexmk -pdf test.tex? – Ashirwad Sep 12 '19 at 21:46