"hold a second job, especially at night," 1957 (implied in moonlighting), from moonlighter (1954), from the notion of working by the light of the moon; see moonlight (n.). Related: Moonlighting. Earlier the word had been used to mean "commit crimes at night" (1882).
To work at a job in addition to one's regular job: a million guys moonlighting, holding a little back (1957+)