Use logger in shell script-Collection of common programming errors

The shebang is correct as both #!/bin/sh and #!/bin/bash can be used*, however, IIRC, you should use pipes not redirect for logger as it’s a program not a file.

Try this script:


#!/bin/sh
ntpd -qnp pool.ntp.org 2>&1 |logger

*If you use #!/bin/sh for your scripts, they are supposed to be posix compliant, ie run well on solaris and AIX. If ever you use some bash specific features, #!/bin/bash have to be used because there’s no more portability.