+
+ # FIXME - this method of checking whether the job was added
+ # to the queue is less than perfect:
+ #
+ # 1. Since the command is the tag, it is possible that there is
+ # already a job in the queue with the same tag. However, since
+ # the tag is what displays in the job list, we can't just
+ # give it a unique ID.
+ # 2. Schedule::At::add() is supposed to return a non-zero
+ # value if it fails to add a job - however, it does
+ # not check all error conditions - in particular, it does
+ # not check the return value of the "at" run; it basically
+ # complains only if it can't find at.
+ # 3. Similary, Schedule::At::add() does not do something more useful,
+ # such as returning the job ID. To be fair, it is possible
+ # that 'at' does not allow this in any portable way.
+ # 4. Although unlikely, it is possible that a job could be added
+ # and completed instantly, thus dropping off the queue.
+ my $job_found = 0;
+ eval {
+ my %jobs = Schedule::At::getJobs(TAG => $command);
+ $job_found = scalar(keys %jobs) > 0;
+ };
+ if ($@) {
+ return 0;
+ } else {
+ return $job_found;
+ }