File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ <h1 >Cron Wrapper</h1 >
2
+
3
+ This dirty tool can execute code more frequently than 1 minute which is crontab minimum setting
4
+
5
+ <h2 >Warning</h2 >
6
+
7
+ executing stuff too frequently can be harmfull for the system. This wrapper does not verifies if the previous execution is finished or not.
8
+
9
+ <b >ENSURE THAT THE CODE IS FINISHING QUICKLY</b >
10
+
11
+ <h2 >Usage</h2 >
12
+
13
+ Add to cron, where X is the delay between executions in seconds
14
+
15
+ * /1 * * * * /root/bin/wrapper X
16
+
17
+ For exemple : every 10 seconds
18
+
19
+ * /1 * * * * /root/bin/wrapper 10
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Wrapper
3
+
4
+ # Initialisation
5
+ if [ " $1 " == " " ]; then
6
+ exit 1
7
+ fi
8
+
9
+ interval=$1
10
+
11
+
12
+ next=$( date +%M | awk -v interval=$interval ' { print int($0 * 60 % interval) }' )
13
+
14
+ if [ $next -gt 0 ]; then
15
+ next=$( echo $next | awk -v interval=$interval ' {print interval - $0}' )
16
+ fi
17
+
18
+
19
+ for i in $( seq $next $interval 59)
20
+ do
21
+ (sleep $i ; echo " do stuff" ) &
22
+ done
You can’t perform that action at this time.
0 commit comments