1

I've configured Heroku's Scheduler to run a Symfony 2 command:

bash app/console myapp:send:confirmations --verbose

And set it to be run each 10 minutes.

But, in the logs I see those messages:

2015-09-10T13:01:25.313711+00:00 heroku[api]: Starting process with command `bash app/console myapp:send:confirmations` by scheduler@addons.heroku.com
2015-09-10T13:01:44.151426+00:00 heroku[scheduler.7629]: Starting process with command `bash app/console myapp:send:confirmations --verbose`
2015-09-10T13:01:44.811500+00:00 heroku[scheduler.7629]: State changed from starting to up
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
2015-09-10T13:01:46.291606+00:00 heroku[scheduler.7629]: State changed from up to complete
2015-09-10T13:01:46.278800+00:00 heroku[scheduler.7629]: Process exited with status 2

Those are the three relevant that are confusing me:

2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file

I'm a bit confused: the file app/console seems not exist, but then the script encounters an unexpected EOF (but the file doesn't exist o.O) and then an unexpected end of file (isn't this the same thing as the message immediatley before?

What am I doing wrong?

Aerendir
  • 6,152
  • 9
  • 55
  • 108

1 Answers1

1

Use php instead of bash to launch the console:

php app/console myapp:send:confirmations --verbose

I have the same behaviour (crash) on Ubuntu 15.04:

$ bash app/console
app/console: line 2: ?php: No such file or directory
app/console: line 18: unexpected EOF while looking for matching `''
app/console: line 23: syntax error: unexpected end of file
$ php app/console -v
Symfony version 2.7.4 - app/prod
...

It seems that the shebang from the start of app/console is ignored and the PHP interpreter is not called:

#!/usr/bin/env php
<?php
....

Here are explanations from Aaron Copley:

It's not executable

Run the binary with absolute or relative path

So if you mark the file as executable and launch the script with relative path, the PHP interpreter will be called:

$ chmod +x app/console
$ ./app/console -v
Symfony version 2.7.4 - app/prod
Community
  • 1
  • 1
A.L
  • 10,259
  • 10
  • 67
  • 98