当我尝试从 php 页面连接到 memcached 服务器时,它可以正常工作。使用此代码
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
但是,当它尝试从 cron 作业触发的 php 脚本连接到服务器时,它会抛出此错误
Warning: Memcache::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/...../cron/acts_cron.php on line 3
Warning: Memcache::connect(): Can't connect to localhost:11211, php_network_getaddresses: getaddrinfo failed: Name or service not known (0) in /home/...../cron/acts_cron.php on line 3
Could not connect
什么会导致这个问题?