How to set cron on alternate Mondays in linux?

September 12, 2017, at 1:45 PM

I want to execute cron on alternate Mondays, how can i set it in linux?
For example, if cron execute on 4th Sept 2017 then next will be
18th Sept 2017
2nd Oct 2017
16th Oct 2017
30th Oct 2017 and so on.
I refer this document but not sure that it is correct or not. If any one has an idea then let me know.

Answer 1

Maybe the solution would be to save somewhere (file, db,...) the last execution date and on every execution check if now is a right day for next execution. In this way you will be have more flexibillity than only with cronjob config.

Answer 2

Not sure if you can do that directly in Cron (probably not), but you for sure you can do it within your script. You can configure your cron task to run daily and then inside your script check if you must do anything or not. For that you can use any resource you need, code, a database to check if the task was run las monday... whatever

SQLSRV doesn't fetch all rows

SQLSRV doesn't fetch all rows

I'm using the sqlsrv extension for php and have a problem with fetching the rows from a simple queryMy query is a select which should return 133228 rows but when trying to display the rows I get only 15

Preg_replace in following string

Preg_replace in following string

I want to replace content from below string,