Make sysctl changes at startup I'd like to change the default smb settings at startup to remove timeouts. I have the following script;

#!/bin/sh

sysctl net.smb.fs.kern_deadtimer=0
sysctl net.smb.fs.kern_hard_deadtimer=0
sysctl net.smb.fs.kern_soft_deadtimer=0


Running this script with sudo sets the relevant kernel options correctly. So I know that these commands are the correct ones.

I have created the following LaunchDaemon in /Library/LaunchDaemons/ to try and get this script to run at startup;

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.jo.sysctl&lt;/string&gt;
    &lt;key&gt;Disabled&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;UserName&lt;/key&gt;
    &lt;string&gt;admin&lt;/string&gt;
    &lt;key&gt;GroupName&lt;/key&gt;
    &lt;string&gt;staff&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/Users/admin/scripts/sysctl.sh&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


I've checked the plist with plutil and it checks out OK. I've set the permissions on the shell script to 0755 and set ownership of the plist file to root:wheel. 

Running

sudo launchctl load /Library/LaunchDaemons/com.jo.sysctl.plist


...does nothing. The defaults are still set incorrectly. Where am I going wrong?

Thanks
It's probably best to ditch the script approach and use the settings file designed for this purpose: sysctl.conf

This applies up to macOS 10.12 Sierra.
as @klanomath pointed out in comments: " *.deadtimer are all "sysctl: unknown oid *.deadtimer" in my High Sierra environment. IE they don't exist!"
So it looks like that part of the sysctl interface is completely gone now.

sudo nano  /private/etc/sysctl.conf


add the following variables:

net.smb.fs.kern_deadtimer=0
net.smb.fs.kern_hard_deadtimer=0
net.smb.fs.kern_soft_deadtimer=0


If you afterwards boot in verbose mode (cmd+v on startup or sudo nvram boot-args="-v" before a reboot), you should see the custom settings being applied.

You should then see on boot messages like these:

net.smb.fs.kern_deadtimer: 60 -&gt; 0
net.smb.fs.kern_hard_deadtimer: 600 -&gt; 0
net.smb.fs.kern_soft_deadtimer: 30 -&gt; 0


Otherwise check with 

sysctl -a | grep smb


This approach should work for most settings that are accessible via sysctl and thus be as generalised as the question title implies.