当前位置:网站首页>When crontab scheduled task executes jar through script, it encounters a pit where jar package execution is invalid
When crontab scheduled task executes jar through script, it encounters a pit where jar package execution is invalid
2022-07-25 08:34:00 【Think twice and keep your heart】
I wrote a simple one VPN The program , The requirement is to obtain the login user ip Address , Then by adding IPtables The rules , Achieve the release function , Everything's ready , meanwhile , By manually executing the script file , It is already possible to add rules .
However, what I never thought of , For the convenience of future use , I choose to use crontab Scheduled tasks come , Every once in a while , Execute the script once . Everything was fine , Results after the deployment , I found the final result , It's different from what I expected , Because he ----- No implementation java Program !!!

what?? I was stunned . It can be done manually , Why timing cannot be executed , It's so hard that I wrote the wrong code ? But , Obviously, it can be implemented , Is it difficult that the script is not executed ? But after adding other commands in the script , Discovery is executable , But when ordered , involves java The execution result of the file , Are unable to succeed . That is to say, the mistake is jar Implementation . After inspection ,java The code is correct , The execution path is also correct . I checked a lot of information on the Internet , then , Discovery execution jar Before the bag , You should first introduce environment variables :
Before the introduction :
java -jar /bbb/vpnTest.jar
After introducing environment variables :
source /etc/profile
java -jar /bbb/vpnTest.jar
And then execute , There is no problem .
边栏推荐
- Svg creative underline style JS special effect
- Test the mock data method of knowing and knowing
- Pet adoption system based on ssm+mysql+layui
- Apartment repair reporting system (idea, SSM, MySQL)
- A simple hotel background management system based on jsp+servlet+mysql
- @The difference and use of value and configurationproperties
- 【黑马程序员】Redis学习笔记001:Redis简介+五种基本数据类型
- [5g NR] UE registration rejection reason
- serialization and deserialization
- @Implementation principle of Autowired annotation
猜你喜欢

How to set up a personal website for free

第3章业务功能开发(修改线索,数据回显并修改数据)

【黑马程序员】Redis学习笔记005:企业级解决方案

uni-app

QA robot sequencing model

Hotel room management system based on jsp+servlet+mysql

Huawei device remote login (Telnet, SSH) configuration
![[dark horse programmer] redis learning notes 004: master-slave replication + sentinel mode + cluster](/img/d8/74cc67240719867cdeceab2cda533f.png)
[dark horse programmer] redis learning notes 004: master-slave replication + sentinel mode + cluster

FreeMaker模板引擎

Apartment repair reporting system (idea, SSM, MySQL)
随机推荐
Nuscenes dataset 3D mot demo, end-to-end target detection and tracking, joint detection and tracking framework
RTOS series (13): assembly LDR instruction, LDR pseudo instruction, [rn] register indirect reference detailed analysis
【着色器实现Shadow投影效果_Shader效果第八篇】
JVM specification Oracle official website
Record the process of two multi terminal troubleshooting
Network packet loss, network delay? This artifact helps you solve all problems
serialization and deserialization
Freemaker template engine
How can hospitals achieve efficient and low-cost operation and maintenance? Is there any software that can meet it?
@Autowired的使用
SSM+JSP+MYSQL实现的宠物领养收养管理系统源码
Blue and white porcelain used by Charles
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
25位撤销博士学位
"Unable to recognize" yarn "item as cmdlet, function, script file
[dark horse programmer] redis learning notes 001: introduction to redis + five basic data types
Raspberry pie creation self start service
Redis learning
C # introductory series (30) -- exception handling
@Feignclient annotated interface. You may not get instances with @autowired