当laravel调度程序启动如下命令时:
$schedule->command('test:testcommand')->hourly();
我需要在命令中找出是否已通过
启动 artisan test:testcommand
或
artisan schedule:run
我调查了$_SERVER['argv']
,但没有任何信息可以帮助我
找出这个。
也许laravel具有一些精美的内部功能,但我找不到它们。
答案 0 :(得分:0)
执行此操作的唯一方法是通过参数进行通信。因此,您可以执行以下操作:
$schedule->command('test:testcommand',['--scheduler'])->hourly();
答案 1 :(得分:-1)
您可以通过事件进行此操作:
import json
jsonstring = '''{
"Localfiles": [{
"IPAddress": ["217.120.103.158"],
"FileLength": 7911088,
"FileName": "desktop.jpeg"
}, {
"IPAddress": ["217.120.103.158"],
"FileLength": 7924192,
"FileName": "Snelleplanga.mp4"
}, {
"IPAddress": ["217.120.103.158"],
"FileLength": 282,
"FileName": "desktop.ini"
}, {
"IPAddress": ["133.234.44.122"],
"FileLength": 7911088,
"FileName": "desktop.jpeg"
}]
}'''
def test(data):
dictionary = {}
dictionary['Localfiles'] = []
s = json.loads(data)
content = s["Localfiles"]
for item in content:
ipaddrarr = item["IPAddress"]
ipaddr = ipaddrarr[0]
filelen = item["FileLength"]
filename = item["FileName"]
dictionarychild = {}
dictionarychild["IPAddress"] = []
dictionarychild["IPAddress"].append(ipaddr)
dictionarychild["FileLength"] = filelen
dictionarychild["FileName"] = filename
dictionary["Localfiles"].append(dictionarychild)
print(dictionary)
test(jsonstring)
然后在您的php artisan make:event OnCommandRun
类的handle()
中触发它:
testcommand
然后在事件event(new OnCommandRun());
函数中执行所需的操作