Your commands are not working because /etc/init.d/smbd
and /etc/init.d/nmbd
have the following at the start:
if init_is_upstart; then
exit 1
fi
So, as the init
in ubuntu is now Upstart (/etc/init.d/
is from SysV), you need to run the start-stop scripts from the directory /etc/init/
. /etc/init.d/
still exists for backward compatibility because many programs still use this directory.
To make things easier for you, Ubuntu has service
command:
sudo service smbd stop
sudo service nmbd stop
While running as root
:
service smbd stop
service nmbd stop
service
will first search in /etc/init/
directory and then /etc/init.d/
. service
is efficient in another sense that if there are two scripts having the same name in those two directories (as in case of smbd
and nmbd
) the Upstart script (in /etc/init/
) will take precedence over SysV script (in /etc/init.d/
).
Also your cron
entry can be made simpler:
0 22 * * 0-4 service samba stop && service smbd stop && service nmbd stop
&&
ensures that the next command is run only if the previous one is successful (i.e. exit code $?=0
).