Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:15:40+00:00 2026-05-29T19:15:40+00:00

I have a Makefile that starts a Django web server. I would like the

  • 0

I have a Makefile that starts a Django web server. I would like the server to be started in the background, with the PID saved to a file.

My recipe looks like this:

run: venv
    @"${PYTHON}" "${APP}/manage.py" runserver 80

Intuitively, to background the process and capture the PID, I’d have to do something like this:

run: venv
    @"${PYTHON}" "${APP}/manage.py" runserver 80 & ; echo "$$!" > "${LOGDIR}/django.pid"

This doesn’t work, though. The sub-shell that ‘make’ uses (/bin/sh in my case) works when you use:

<command> &

…to background a process, and works when use:

<command> ; <command>

(or <command> && <command>, etc…) to chain commands. However, when I try to background the first process and chain a second one, I get the following error:

/bin/sh: -c: line 0: syntax error near unexpected token `;'

What is the best way to background a process and capture the PID in a Makefile?

Thanks
– B

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:15:42+00:00Added an answer on May 29, 2026 at 7:15 pm

    Just leave a single ampersand, without a semicolon after it:

    run: venv
        @"${PYTHON}" "${APP}/manage.py" runserver 80 & echo "$$!" > "${LOGDIR}/django.pid"
    

    Ampersand acts as command separator in the same way as a semicolon:

    <command> & <command>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I have a makefile that looks like: default: lua blah.lua Now, in Vim, I
I have a C++ eclipse project that I would like to easily compile In
For a peice of work I have created a web server that handles multiple
I have a Makefile rule that generates an MD5 hash for a file, compares
i have created a Makefile which i would change so, that it will generate
I have a working makefile that builds with mingw32. Now i renamed that makefile
I have a makefile project that builds and links a DLL, using the command-line
I have a section of makefile that has this sort of structure: bob: ifdef
I have a project that has a makefile with broken dependencies. Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.