2

I have a CentOS Server. When the server Boots up I want to execute a command after 10 minutes of booting up. How can I do so?

$ /usr/bin/curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop HDFS via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services/HDFS
3

try to write in a shell run at boot

at now +10 minutes <<EOF
/usr/bin/curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop HDFS via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://AMBARI_SERVER_HOST:8080/api/v1/clusters/CLUSTER_NAME/services/HDFS
echo hello curl > /tmp/curl.log
EOF
  • a good place, is at the end of /etc/rc.local, or /etc/rcX.d if your are more familiar with run-level.
  • creation time of /tmp/curl.log will tell you if curl ran.
  • hi could please tell me with my complete command statement – Shahrukh Khan Oct 16 '15 at 12:27
4

You can do this in cron too. Just add in /etc/crontab:

@reboot /bin/sleep 600 && COMMAND
0

If you're running CentOS 7, you can also use systemd timer units (see man systemd.timer). In particular, here, you can use the OnBootSec= directive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.