Skip to main content

Using a Cron Job with the "sysctl -p" Command to Speed up Sites

Comments

4 comments

  • cPanelLauren
    Just running that command I can't see how it would really change anything. Here is the man page for sysctl: SYSCTL(8) System Administration SYSCTL(8) NAME sysctl - configure kernel parameters at runtime SYNOPSIS sysctl [options] [variable[=value]] [...] sysctl -p [file or regexp] [...] DESCRIPTION sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl support in Linux. You can use sysctl to both read and write sysctl data. PARAMETERS variable The name of a key to read from. An example is kernel.ostype. The '/' separator is also accepted in place of a '.'. variable=value To set a key, use the form variable=value where variable is the key and value is the value to set it to. If the value contains quotes or characters which are parsed by the shell, you may need to enclose the value in double quotes. This requires the -w param? eter to use.
    -p[FILE], --load[=FILE] Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. Specifying - as filename means reading data from standard input. Using this option will mean arguments to sysctl are files, which are read in the order they are specified. The file argument may be specified as regular expression.
    Are you loading specific settings from a certain file?
    0
  • celiac101
    Yes, it loads settings that I've tweaked in /etc/sysctl.conf net.ipv4.tcp_wmem=4096 12582912 16777216 net.ipv4.tcp_rmem=4096 12582912 16777216 net.core.rmem_max=16777216 net.core.wmem_max=16777216 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 vm.overcommit_memory = 1 fs.file-max = 2097152 net.core.netdev_max_backlog = 131070 net.core.somaxconn = 131070 net.ipv4.tcp_max_syn_backlog = 3240000 net.ipv4.tcp_max_tw_buckets = 1440000 net.ipv4.tcp_window_scaling = 1 vm.swappiness = 30
    The settings are already correctly running when I run the "sysctl -p" command, I have verified this, which is why I find this so strange. I have confirmed this speed increase many times over, which is what led me to this quest to discover what else this command could be doing: sysctl -p Hopefully I've set the cron job up correctly in my /var/spool/cron/root file: SHELL="/bin/bash" */15 * * * * sysctl -p >/dev/null 2>&1 I suspect it must clear out a cache somewhere with the old settings, and this somehow speeds things up. I am no server expert, but can testify that this command results in a site speed increase.
    0
  • celiac101
    Would this be the proper way to set up the cron job? I am not sure if it is working the same as when run on the command line: SHELL="/bin/bash" */15 * * * * sysctl -p >/dev/null 2>&1
    0
  • cPanelLauren
    Yea that would run the cron every 15 minutes.
    0

Please sign in to leave a comment.