3

It seems that there is no difference between nohup and at now, but maybe there are subtleties?

hlovdal
  • 26,565
  • 10
  • 94
  • 165
erkfel
  • 1,588
  • 2
  • 17
  • 29

3 Answers3

5

The difference is that now runs a command that can respond to HUP signal, where as the nohup runs a command that is immune to HUP signal.

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
2

Ed Heal is right. But another difference is that something run by nohup still has a controlling terminal, whereas something run by at now does not.

In addition to that, backgrounding something with nohup causes it to run immediately, whereas at now simply queues something to be run the next time atrun(8) runs. In BSD unix, (FreeBSD/OpenBSD) at jobs are launched by atrun which is launched periodically by cron (or launchd in OSX). In Linux, at jobs are run by at's own daemon, atd, which by default launches jobs every 60 seconds.

Other flavours of unix may have different strategies, but in most cases you'll probably find that jobs launched by at now are less immediate than jobs launched using nohup.

ghoti
  • 45,319
  • 8
  • 65
  • 104
  • You are incorrect about the environment variables. Please take a look at http://linux.die.net/man/1/at (you can test this out by looking at the scripts that `at` creates (int `/var/spool/at `). But +1 for the note about the controlling terminal – Ed Heal Aug 17 '12 at 12:15
  • Hmm, right you are about environment. Not sure what your platform is though -- on FreeBSD, jobs live in `/var/at/job/`. Thanks, I've updated my answer accordingly. – ghoti Aug 17 '12 at 16:28
  • Your welcome. Have a pleasant weekend. It is also to know that as you can check. – Ed Heal Aug 17 '12 at 16:31
  • What are the possible consequences of those differences, i.e. being immune to SIGHUP and having a controlling terminal? – Olivier Gérardin Nov 14 '18 at 13:50
-1

nohup tells the system to continue running even after you log out. at is used to execute a command or multiple commands once at some future time.

Gopal SA
  • 949
  • 2
  • 17
  • 36