@@ -38,15 +38,14 @@ box_bin_alive() {
3838}
3939
4040box_run_crontab () {
41- # start crond with the "-c" option and keep it in the background
42- nohup busybox crond -c " ${box_run} " > /dev/null 2>&1 &
43- # delete the previous crontab and create a new crontab
41+ # Stop crond if it is running (optional)
42+ pkill -f " busybox crond" > /dev/null 2>&1
43+ # Prepare crontab
4444 busybox crontab -c " ${box_run} " -r
45- touch " ${box_run} /root"
46- chmod 0755 " ${box_run} /root"
45+ echo " # cron tasks for root" > " ${box_run} /root"
4746
4847 if [ " ${run_crontab} " = " true" ]; then
49- log Debug " crontab job enabled "
48+ log Debug " crond enable "
5049 if [ " $update_subscription " = " true" ] || [ " $update_geo " = " true" ]; then
5150 log Debug " Interval crontab: ${interva_update} ."
5251 echo " ${interva_update} ${scripts_dir} /box.tool geosub" >> " ${box_run} /root"
@@ -55,8 +54,12 @@ box_run_crontab() {
5554 log Info " ${bin_name} subscription update: ${update_subscription} ."
5655 fi
5756 fi
57+ cat " ${box_dir} /crontab.cfg" >> " ${box_run} /root"
58+ chmod 0644 " ${box_run} /root"
59+ # start crond with the "-c" option and keep it in the background
60+ nohup busybox crond -c " ${box_run} " > /dev/null 2>&1 &
5861 else
59- log Info " crontab Job disabled "
62+ log Info " crond disable "
6063 fi
6164}
6265
@@ -594,15 +597,15 @@ box_bin_status() {
594597
595598 # Save the process ID to the pid file
596599 if [ -n " $PID " ]; then
597- sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 😎 $bin_name service is running!!! ] /g" " $PROPFILE "
600+ sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 🍀 $bin_name service is running!!! ] /g" " $PROPFILE "
598601 echo -n " $PID " > " ${box_pid} "
599602 fi
600603}
601604
602605start_box () {
603606 # Clear the log file and add the timestamp and delimiter
604607 # cd /data/adb/box/bin; chmod 755 *
605- sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 😵💫 Module is working! but no service is running ] /g" " $PROPFILE "
608+ sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 🙂↔️ Module is working! but no service is running ] /g" " $PROPFILE "
606609
607610 echo -n " " > " ${box_log} "
608611 box_version=$( busybox awk ' !/^ *#/ && /version=/ { print $0 }' " /data/adb/modules/box_for_root/module.prop" 2> /dev/null)
@@ -757,16 +760,18 @@ stop_box() {
757760 force_stop
758761 fi
759762
760- sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 🥶 $bin_name shutting down, service is stopped !!! ] /g" " $PROPFILE "
763+ sed -Ei " s/^description=(\[.*][[:space:]]*)?/description=[ $current_time | 😱 $bin_name shutting down, service is stopped !!! ] /g" " $PROPFILE "
761764}
762765
763766stop_cron () {
764- # Find cronjob PID using `pgrep`
767+ # Stop crond with pkill
768+ if ! busybox pkill -f " busybox crond" > /dev/null 2>&1 ; then
769+ # If pkill fails, find and kill the process
765770 cronkill=$( busybox pgrep -f " crond -c ${box_run} " )
766771 for cron in ${cronkill[@]} ; do
767- # kill cronjob
768- kill -15 " ${cron} "
772+ kill -15 " ${cron} " 2> /dev/null
769773 done
774+ fi
770775}
771776
772777force_stop () {
0 commit comments