【Shell】Shell脚本重复执行某一段代码

1. 编写shell脚本

  • 创建并打开sh文件
vi ./send.sh
  • 编写脚本语言
#!/bin/sh
while [ true ]; do
/bin/sleep 1
'此处填写需要重复执行的程序' >> ./send_log.txt //此处为存储log的地址
done

2. 后台运行

nohup ./send.sh &

3. 确认每秒执行

tail -f ./send_log.txt

4. 停止脚本运行进程

ps -ef | grep send.sh | kill -9
  • 或者直接kill程序端口

长安链一些evm合约调用相关

$ cd ../../scripts/
$ ./cluster_quick_start.sh normal     ## scripts下
$ cd ../tools/cmc
$ ./send.sh &

$ tail -f ./send_out.log
$ ps -ef | grep send.sh |kill -9


$ ./cmc client contract user create \
--contract-name=balance001 \
--runtime-type=EVM \
--byte-code-path=./testdata/balance-evm-demo/ledger_balance.bin \
--abi-file-path=./testdata/balance-evm-demo/ledger_balance.abi \
--version=1.0 \
--sdk-conf-path=./testdata/sdk_config.yml \
--admin-key-file-paths=./testdata/crypto-config/wx-org1.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org2.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org3.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org4.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org5.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org6.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org7.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org8.chainmaker.org/user/admin1/admin1.sign.key,./testdata/crypto-config/wx-org9.chainmaker.org/user/admin1/admin1.sign.key \
--admin-crt-file-paths=./testdata/crypto-config/wx-org1.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org2.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org3.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org4.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org5.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org6.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org7.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org8.chainmaker.org/user/admin1/admin1.sign.crt,./testdata/crypto-config/wx-org9.chainmaker.org/user/admin1/admin1.sign.crt \
--sync-result=true


$ ./cmc client contract user invoke \
--contract-name=balance001 \
--method=updateBalance \
--sdk-conf-path=./testdata/sdk_config.yml \
--params="[{\"uint256\": \"10000\"},{\"address\": \"0xa166c92f4c8118905ad984919dc683a7bdb295c1\"}]" \
--sync-result=true \
--abi-file-path=./testdata/balance-evm-demo/ledger_balance.abi

p3JMwWESysNpbVHRGsciJYG7rZ5KGj4ig69s2h3gx3U
0xa166c92f4c8118905ad984919dc683a7bdb295c1

Reference

shell脚本实现每秒执行一次任务

猜你喜欢

转载自blog.csdn.net/miracleoa/article/details/126858724