Linux at command hangs?

1

I'm having a problem with the Linux 'at' command, and it's quite tough to Google 'at'.. The problem is that whatever I run, it doesn't seem to ever stop.

e.g. here is a simple script I made (I replaced my username with USER):

#!/bin/bash
echo "Testing" > /local/USER/tmp.txt

I placed the above lines into a file /local/USER/tmp.sh and made the file executable. Running it with

/local/rarandje/tmp.sh

works as expected and creates the relevant file.

Now, if I try with the 'at' command:

at -f /local/USER/tmp.sh now + 1 min

it starts executing at the desired time but it just hangs there, this is the output of at -l:

10      Wed Jan 21 15:06:00 2015 = USER
10      Wed Jan 21 15:06:00 2015 a USER

The output tmp.txt file is not created, there is no 'echo' or 'tmp.sh' command in the process list, so I don't really understand what's the problem and how to debug it.

One thing to note which might be relevant, though it might also be completely irrelevant and sidetrack you: the root user doesn't have permissions to my home folder (I am in a company which stores home folders on the network and are mounted via NAS, so the local root user on my machine actually doesn't have rights to even read the NAS mounted ~ folder as the local root is not the same as the remote root). However, root does definitely have read/write access to /local/USER/ as that's just a local disk. Not sure if this is in any way relevant, e.g. maybe there's something at the start of the 'at' command that is executed by root and needs to read my bash profile or whatever, but it still doesn't make sense, I would at least expect the job to fail and not to continuously "run".

I'm on Ubuntu 12.04.4 and have (local) root access. Thanks in advance.

EDIT: I just tried the same thing as a root, i.e. just running the same 'at' command as the root user, and it all works fine, the output file is created and the job terminates.

Relja Arandjelović

Posted 2015-01-21T14:36:14.220

Reputation: 143

Answers

2

After @maiki posted this comment and I looked at the /var/log/syslog and saw this error (I anonymized it with HOSTNAME and USERID):

Jan 21 17:53:32 HOSTNAME atd[27285]: Userid USERID not found - aborting job       14 (a0000e016998f5)

After Googling a bit I found this post which basically says that atd should be ran after ypbinding when the computer is started if there are any non-local users (I am not an expert in the way the computer is set up, I have a network username which I use to connect to my PC and everyone from my company can connect in the same way to my PC). I just restarted atd with sudo service atd restart and my 'at' jobs are running fine now. Not sure how to fix this permanently so that I don't have to restart 'atd' myself every time I restart the computer, but I'll try to figure it out (and edit this answer)

Relja Arandjelović

Posted 2015-01-21T14:36:14.220

Reputation: 143

0

Add your username to /etc/at.allow (create it if it does not exist)

As per the manpage:

  • if /etc/at.allow exists, the users mentioned have access to at
  • else if /etc/at.deny exists, all users have access to at except those mentioned into the file.
  • else only root has access to at

maiki

Posted 2015-01-21T14:36:14.220

Reputation: 421

The file didn't exist, I created it and added my username to it. My user is not present in /etc/at.deny . It didn't work, there is no change. In fact if I wasn't allowed to use 'at' then this would be reported at the start (e.g. for 'fun' I tried adding my name into /etc/at.deny and when attempting to run 'at' I would get 'You do not have permission to use at.') – Relja Arandjelović – 2015-01-21T15:15:20.760

@user1939941 In your question you speak about mounted via NAS. Is it a NFS mount? at sends error via mail to the user invoking it. Did you receive any? If you remove > /local/USER/tmp.txt from your script, does it work? – maiki – 2015-01-21T15:32:19.383

Not sure how to check if it is an NFS mount but I think it is. I don't get any mail at all from 'at', but I've also noticed some problems with 'mail' that I'm trying to resolve (I can send mail to USER from root, but not to root from USER, though I can send to myself (USER to USER); not sure if it is connected. Removing the > /local/USER/tmp.txt doesn't make any difference, and I wouldn't expect it since both USER and root have write access there (I checked and ran manually the script without 'at') – Relja Arandjelović – 2015-01-21T16:17:16.747

1@user1939941 launch at -f /local/USER/tmp.sh now and check the latest lines of /var/log/messages and /var/log/secure – maiki – 2015-01-21T16:44:14.020

Thank you, this led me into a good direction and I got it resolved now! I'll post the solution shortly as a separate answer. Btw, for Ubuntu 12.04 these logs are at different places: /var/log/syslog and /var/log/auth.log (?) – Relja Arandjelović – 2015-01-21T17:03:43.130

@user1939941 glad it has helped – maiki – 2015-01-21T18:27:34.453