0

So I have two tasks (let's say TaskA and TaskB). I want both tasks to run hourly, but TaskB requires TaskA. TaskB does not have any parameters, but TaskA has two parameters for the day and the hour. If I run TaskB on the command line, would I need to pass it arguments?

BlaqICE
  • 199
  • 11

2 Answers2

1

In general, you would not need to pass the parameters for Task A to Task B, but Task B would then need to generate the values of those parameters for Task A. If Task B can not generate those parameters, you would have to setup Task B to take those parameters in from the command line, and then pass them through to the Task A constructor in the requires method.

MattMcKnight
  • 7,915
  • 26
  • 34
1

Well if TaskB requires TaskA but TaskB doesn't accept any parameters, then it probably requires TaskA for current date and time. If this assumption is true, then it's enough to run TaskB @hourly in cron without any parameters, and define it's requires() method to yield TaskA with current date and time.

On the other hand, if TaskB requires TaskA at some specific point in time, it should have DateHourParameter() itself (which is by the way preferred way to parametrize task with date and time - unless you need more precision, then take a look at DateMinuteParameter() or DateSecondParameter() over two parameters one for date, another for time) and then yield requirement for TaskA with own parameter's value.

Yakuza
  • 2,037
  • 2
  • 16
  • 18