1. Write one shell script
2. Add that into cron job
3. Restart the cron service
1. /opt/folder/filename.sh
#!/bin/bash
# Grabs and kill a process from the pidlist that has the word mq
pid=`ps aux | grep api.jar | awk '{print $1}'`
kill -9 $pid
pid=`ps aux | grep api.jar | awk '{print $2}'`
kill -9 $pid
#!/bin/bash
nohup java -jar /opt/folder/api.jar & \n
2. Open vi /etc/crontab
> crontab -e //to edit cronfile
2. Add that into cron job
3. Restart the cron service
1. /opt/folder/filename.sh
#!/bin/bash
# Grabs and kill a process from the pidlist that has the word mq
pid=`ps aux | grep api.jar | awk '{print $1}'`
kill -9 $pid
pid=`ps aux | grep api.jar | awk '{print $2}'`
kill -9 $pid
#!/bin/bash
nohup java -jar /opt/folder/api.jar & \n
2. Open vi /etc/crontab
> crontab -e //to edit cronfile
> crontab -l //to list cron settings
> crontab -d //to delete cron settings
# m h dom mon dow user command
10 6,14 * * * root sh /opt/folder/filename.sh
#to store logs in custom folder
To see system log or custom log
*/1 * * * * /usr/bin/python3 /opt/drvijay/applications/backend/testcorn.py >> /opt/drvijay/logs/testcorn.log 2>&1
3. Run
service cron stop
service cron start
service cron stop
service cron start
To see system log or custom log
grep CRON /var/log/syslog
tail -f /var/log/syslog | grep CRON
tail -f /var/log/syslog | grep CRON
tail -f /opt/drvijay/logs/testcorn.log
it will run 6:10 AM, 2:10 PM.