i use fallowing command to excute my script in every 30 min
*/30 * * * * /home/g-m-iqbal/Desktop/Auto/algo.sh
and also try this
*/30 * * * * /home/g-m-iqbal/Desktop/Auto/ && sh algo.sh
here
/home/g-m-iqbal/Desktop/Auto this the path of script
Related
I am trying to uncomment "/usr/lib/sa/sa1" or "/usr/lib/sa/sa2" entries from one of the configuration file.
Below is the regex:
"^[0-9].*/usr/lib/sa/sa(1|2)"
Eg:
#0 * * * * /usr/lib/sa/sa1 1200 3 &
#5 23 * * * /usr/lib/sa/sa2 -s 0:00 -e 23:01 -i 3600 -ubcwyaqvm &
Output should be:
0 * * * * /usr/lib/sa/sa1 1200 3 &
5 23 * * * /usr/lib/sa/sa2 -s 0:00 -e 23:01 -i 3600 -ubcwyaqvm &
Tried the below "sed" command but no luck:
sed -e '/^#.*\/usr\/lib\/sa\/sa\(1\|2\)/s/^#//g' adm
Can you please let me know where am I going wrong here.
Thanks in advance!
You can use
sed '/^#.*\/usr\/lib\/sa\/sa[12]/s/^#//'
Here, no grouping construct is used, no alternation operator is used either. It is possible as the 1 and 2 are single char alternatives, and bracket expressions are supported in all versions of sed.
Also, see this online demo.
I have a cron job with below details
The timing section is unknown, it might be hourly or daily.
cat zyx.txt
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 * * * * root /usr/local/bin/log-cleaner
I have to update it on the fly using sed, so that it should run every minute .
Here is what I have tried
sed -in 's/\(.*\) \(.*\) \(.*\)/\* \* \* \* \*/1' zyx.txt
But it is removing the user and path section
cat zyx.txt
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * *
Any help / suggestion using sed is much appreciated
I have a cron properties file and some of the properties contain expression like:
"* 0/5 * * * ?"
and some of them contain:
"* */5 * * * ?"
What is the difference between the two?
If I want to run every 5 minutes then which one should be used?
Thanks
PS: My project is using spring scheduler.
You can use "*/5 * * * * *" for every 5 minutes and 0 0/5 8-10 * * * for every 5 minutes between 8 o'clock and 10 o'clock
For more info read this
So i have simple shell commands to ping websites to retrieve data about said websites.
For example one of my pinging.sh looks like this:
ping -R -c 120 blar.org.cn >> pingdata.txt
ping -R -c 120 another.net >> pingdata.txt
But then my crontabs look like this:
7 * * * ./pinging.sh >> pingdata.log
The pingdata.log doesn't output. Is it best to do it through the crontab or through the script? I assumed the crontab would be better because it would cover the entire script rather than having to write it out multiple times.
You need to indicate the full path of your script in the cronjob, together with the binary running it.
For example:
7 * * * * /bin/sh /home/you/pinging.sh >> /home/you/pingdata.log
Note also you are just adding 4 parameters to the cronjob, whereas you need at least 5:
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
You can test your cron syntax with Crontab guru (---> http://crontab.guru/).
First, the executable must be provided as full path in cron.
Example:
7 * * * * /bin/bash /path/to/pinging.sh
Second, create a wrapper script for pinging.sh >> pingdata.log and add that to crontab.
Third, your crontab entry is wrong. There must be 5 fields whereas your's have 4 (maybe that's a typo ?)
I want to add time-lag between same role. e.g. roles :app = [app1, app2, app3]
My expectation(pseudo code):
app1: "1 * * * * rake 'heavy:task'"
app2: "3 * * * * rake 'heavy:task'"
app3: "2 * * * * rake 'heavy:task'"
1,2,3 is not important, but time-lag is important.
How to add time-lag between same role?
My actual schedule.rb:
every :hour, roles: [:app] do
rake 'heavy:task'
end
Actual result(pseudo code):
app1: "0 * * * * rake 'heavy:task'"
app2: "0 * * * * rake 'heavy:task'"
app3: "0 * * * * rake 'heavy:task'"
My stab at this. Sleep randomly for 6 seconds, executed serverside
every :hour, roles: [:app] do
on :all, in: :parallel do
execute 'sleep #{rand(6)}'
rake 'heavy:task'
end
end