我正在尝试在init.d
文件夹中设置新服务,但是这次我遇到了一个奇怪的问题。我创建了一项新服务,并在其中添加了回声:
echo "asdsad"
当我不带参数调用它时,看起来很完美:
brunomanzo@platform-hdfs-01:/etc$ sudo service hadoop-hdfs
asdsad:
但是当我使用开始/停止参数进行调用时,它不会打印任何内容:
brunomanzo@platform-hdfs-01:/etc$ sudo service hadoop-hdfs start
答案 0 :(得分:1)
1)文件必须位于/etc/init.d /
2)您缺少此
sudo chmod 755 /etc/init.d/hadoop-hdfs
sudo chown root:root /etc/init.d/hadoop-hdfs
测试后的结果
root@server:/# echo "echo \"Test service\"">> /etc/init.d/hadoop-hdfs
root@server:/# chmod 755 /etc/init.d/hadoop-hdfs
root@server:/# chown root:root /etc/init.d/hadoop-hdfs
root@server:/# sudo service hadoop-hdfs
Test service
root@server:/# sudo service hadoop-hdfs start
Test services
root@server:/# service hadoop-hdfs start
Test services
经过测试
1) with sudo
2) without sudo
3) with start
4) without start