Usage notes for Command

更新时间:
复制 MD 格式

Because of limitations in ECS Cloud Assistant, you must follow specific rules when you use Command to deploy applications with Alibaba Cloud Toolkit. This topic describes these rules and provides examples.

Usage notes

When you use Command to deploy applications with Alibaba Cloud Toolkit, note the following:

  • Commands are executed by the root user. To run a command as a different user, switch the user within the script.

  • Do not use the sleep command in your script.

  • Do not use non-terminating commands, such as tail -f, in your script.

Example

The following script was used in an attempt to deploy an application, but the script failed to execute.

#! /bin/shell
pkill -f test.jar
sleep 5
rm -rf test.log 
nohup java -jar test.jar > test.log &
tail -f test.log
            

Analysis:

  • The script contains a sleep command, which must be removed.

  • The script contains the non-terminating command tail -f. This command must be removed.

Modify the script as follows to ensure that it runs successfully. These changes are based on the usage notes for Command.

#! /bin/shell
source /etc/profile
pkill -f test.jar
rm -rf /home/test.log
nohup java -jar /home/test.jar > /home/test.log &