I am new to Linux and I want to have a script to run ClamAV on my entire system, write it to a log file, then shut down after it is done (since I will be running it before I go to bed). I already made it executable. This is what I have so far:

sudo clamscan -r -i / > clamav.log
  • AskUbuntu supports Ubuntu and official derivatives only. Mint is not one of them. In the future you may want to post your questions at unix.stackexchange.com
    – user589808
    Apr 16, 2017 at 2:27
  • #!/bin/bash not ~. Instead of using sudo in scripts, run the script with sudo. ClamAV runs as a daemon and writes a log by default whenever it runs. You do not need to manually run it.
    – Zanna
    Apr 16, 2017 at 5:41
  • @Zanna Where is the log file located at?
    – R_C
    Apr 17, 2017 at 3:24
  • Should be in /var/log/clamav
    – Zanna
    Apr 17, 2017 at 4:50
  • @Zanna So should the script just look like this? #!/bin/bash clamscan -r --bell -i /
    – R_C
    Apr 17, 2017 at 5:57

1 Answer 1


Based on the manual page of clamscan(1):

clamscan -r -i --stdout / > /path/to/clamav.log
exec poweroff

Mark the script file with the above content as executable,

chmod +x scan-and-poweroff.sh

and execute it as super-user,

sudo scan-and-poweroff.sh

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