How do I format these two complex cron statements?


HOME ยป Unix

I need two very specific cron statements:




  1. A cron entry that would run on the 2nd Monday of each month
    every 4 hours beginning at 02:00 and execute the file
    /opt/bin/cleanup.sh


  2. A cron entry that would run at 18:15 on the 3rd day of every
    month ending in an "r" that executes /opt/bin/verrrrrrrry.sh




I've already tried various cron testers:



cron
checker
, rel="nofollow">cron tester,and href="https://crontranslator.appspot.com/" rel="nofollow">cron
translator



however none of them seem to be able to handle advanced cron
expressions(or I do not know how to format the correct expression) as
stated on



href="http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger"
rel="nofollow">the cron trigger tutorial and
rel="nofollow">wikipedia



How can I check my cron statements? I obviously cannot wait for the
actual event to pass so that the daemon may execute them.



Is there a good cron tester which supports advanced expressions? Or
how to make the cron daemon parse the expression, or how to code these
expressions?



What I have so far for these statements is:




  1. 0 2 * * 0#2 /opt/bin/cleanup.sh

  2. 15 18 3 * * /opt/bin/verrrrrrrry.sh



But of course these are not correct.



For #1, I do not know how to specify the '2nd Monday', nor 'every 4
hours', while still beginning at 02:00.



For #2, I have no idea how to only specify months ending in an 'r'
except by manually coding them in. Nor do I know how to specify the
3rd day.

/**
* Computes and returns the Date on which Thanksgiving will fall
* in a given year.
*
* NOTE: By law, Thanksgiving is the 4th Thursday in November
*
* @param year the year for which to compute the date of Thanksgiving
* @return the Date of Thanksgiving for the specified year
*/

public Date getThanksgiving(int year)
{

int weekcount = 0 ; // record the amount of weeks that has
passed

Date thanksgiving = new Date (11 , 1 , year) ;

while ( weekcount < 4 )
{
thanksgiving.next(); // add one to date

if (thanksgiving.getDayOfWeek().equals("Thursday"))// check
if the day of week is Thursday
{
weekcount++ ; // add one to weekcount
}

if (weekcount == 4)
{

System.out.println(thanksgiving.getLongDate());

}


}



return thanksgiving ;
}


I am not supposed to have that println statement instead i am
supposed to return the correct date using the return statement. The
problem is that I am getting this "Date@2f4d3709" as my output.
Date class-- rel="nofollow">http://users.cis.fiu.edu/~shawg/2210/Date.html

Web Development

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Dim i as Integer
i = ab.text
Dim x1 as double
x1 = textbox(i).text
End Sub

Web Development

I am using rel="nofollow">node-mysql to query a MySQL database via Express
and Node. My queries are getting fairly complex and I want to format
them across multiple lines. However, the only way I could accomplish
this was to put backslashes at the end of each line, as seen
below.



connection.query("SELECT 
`assignments`.`id` AS `aid`,
`assignments`.`name` AS `aname`,
`assignments`.`due`,
`sections`.`id` AS `sid`,
`sections`.`name` AS `sname`,
COUNT(`enrollment`.`student_id`) AS `total`
FROM `assignments`
JOIN `sections` ON `sections`.`id` =
`assignments`.`section_id`
LEFT JOIN `enrollment` ON `sections`.`id` =
`enrollment`.`section_id`
WHERE `sections`.`teacher_id` = ?
GROUP BY `assignments`.`id`
ORDER BY
`assignments`.`due` DESC,
`assignments`.`name` ASC,
`sections`.`name` ASC", [id], function(err, rows)
{


Is there a cleaner way to do accomplish this?

Programming Languages

I have such a function:



let ScanColors() =
for i in 1..54 do
let mutable c = Unchecked.defaultof<string>

if (i = 9) then
c <- "U - WHITE"
else
if (i <> 0 && i%9 = 0) then
MoveSensor(SensorPos.THIRD)
else
MoveSensor(
match ((i - (i/9)*9)%2 <> 0) with
| true -> SensorPos.SECOND
| false -> SensorPos.FIRST)

while (true) do
c <- ScanColor()
if (c = "ERR") then
CalibrateSensorPosition()
else
break
ResetSensorPosition()


in this function, in the whilestatement, I cannot use
break, because as you know, break is not used in F#. I
was looking for alternatives for break, and I saw this
link:



href="http://stackoverflow.com/questions/16543548/f-break-from-while-loop">F#
break from while loop



But to be honest, I couldn't be sure whether this solution suits
with my problem.

Web Development

4,7,33 308:0.364759856031284 1156:0.273818346738286
1523:0.17279792082766 9306:0.243665855423149
7,4,33 1156:0.185729429759684 1681:0.104443202690279
5351:0.365670526234034 6212:0.0964006003127458



I have a textfile in the above format. The first 3 columns are
labels and need to be extracted into another file keeping the order
intact.



As one proceeds through the file, each row has varying number of
labels. I have been reading the csvread function in Matlab but that is
generic and would not work in the above case.



Next, I need to extract
308:0.364759856031284 1156:0.273818346738286 1523:0.17279792082766
9306:0.243665855423149
such that at column 308 in the Matrix for Row 1, I put in the value
0.364759856031284.



I am working on this now but meanwhile any suggestions will be
welcome.

Web Development

I need two very specific cron statements:




  1. A cron entry that would run on the 2nd Monday of each month
    every 4 hours beginning at 02:00 and execute the file
    /opt/bin/cleanup.sh


  2. A cron entry that would run at 18:15 on the 3rd day of every
    month ending in an "r" that executes /opt/bin/verrrrrrrry.sh




I've already tried various cron testers:



cron
checker
, rel="nofollow">cron tester,and href="https://crontranslator.appspot.com/" rel="nofollow">cron
translator



however none of them seem to be able to handle advanced cron
expressions(or I do not know how to format the correct expression) as
stated on



href="http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger"
rel="nofollow">the cron trigger tutorial and
rel="nofollow">wikipedia



How can I check my cron statements? I obviously cannot wait for the
actual event to pass so that the daemon may execute them.



Is there a good cron tester which supports advanced expressions? Or
how to make the cron daemon parse the expression, or how to code these
expressions?



What I have so far for these statements is:




  1. 0 2 * * 0#2 /opt/bin/cleanup.sh

  2. 15 18 3 * * /opt/bin/verrrrrrrry.sh



But of course these are not correct.



For #1, I do not know how to specify the '2nd Monday', nor 'every 4
hours', while still beginning at 02:00.



For #2, I have no idea how to only specify months ending in an 'r'
except by manually coding them in. Nor do I know how to specify the
3rd day.

Unix

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow