cron does not read $PATH or Gnome Schedule doco is insufficient

Bug #1532999 reported by Humphrey van Polanen Petel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-schedule (Ubuntu)
New
Undecided
Unassigned

Bug Description

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Gnome _schedule command preview=/usr/local/bin/bup && tail -f /var/mail/humphrey >~/Desktop/bup-log

/usr/local/bin contains bin

log contains
--
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/humphrey>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=humphrey>
Message-Id: <20160110054001.2130AF227EB@David>
Date: Sun, 10 Jan 2016 16:40:01 +1100 (AEDT)

/bin/sh: 1: bup: not found
--

either
cron does not read PATH
or
Gnome Schedule doco is insufficient for me to understand where to put the script that I want to be run

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: gnome-schedule 2.1.1-4
ProcVersionSignature: Ubuntu 3.16.0-57.77~14.04.1-generic 3.16.7-ckt20
Uname: Linux 3.16.0-57-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.19
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Jan 12 10:31:47 2016
ExecutablePath: /usr/share/gnome-schedule/gnome-schedule.py
InstallationDate: Installed on 2015-09-08 (125 days ago)
InstallationMedia: Ubuntu 14.04.2 LTS "Trusty Tahr" - Release amd64 (20150218.1)
InterpreterPath: /usr/bin/python2.7
PackageArchitecture: all
SourcePackage: gnome-schedule
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :
Revision history for this message
GauteHope (eg) wrote : Re: [Bug 1532999] [NEW] cron does not read $PATH or Gnome Schedule doco is insufficient

do you use the full path to bup in gnome-schedule? The environment that
the preview runs in is not exactly the same as the cron environment, you
have to specify the PATH on that line in that case. Also, is
/usr/local/bin/bup marked executable?

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :

Yes, I do use the full path to bup
Gnome _schedule command preview=/usr/local/bin/bup && tail -f /var/mail
and /usr/local/bin is where bup is

/usr/local/bin/bup is executable, as is evidenced by me being able to do a "run selected task" in Gnome _schedule

You say "The preview runs in is not exactly the same as the cron environment, you have to specify the PATH on that line in that case"
I don't understand what you mean here.

Revision history for this message
GauteHope (eg) wrote :

Is /bin/sh present, is bup a shell script with #! /bin/sh at the top?

Is /usr/local/bin/bup readable and executable by the correct user? Could
you send the exact (except to anonymize) output of:

$ stat /usr/local/bin/bup # and
$ crontab -l

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :

humphrey@David:~$ /bin/sh
$ exit
humphrey@David:~$ cat /usr/local/bin/bup
#!/bin/bash
# file: bup
# date: 2016-01-12

echo "backup to network drive"
echo "*"
echo "************************************************************************"
echo "Desktop"
echo "*"
cp --backup=simple -r -u -v ~/Desktop /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Documents"
echo "*"
cp --backup=simple -r -u -v ~/Documents /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Downloads"
echo "*"
cp --backup=simple -r -u -v ~/Downloads /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Google Drive"
echo "*"
cp --backup=simple -r -u -v "Google Drive" /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Gummitch reinstall"
echo "*"
cp --backup=simple -r -u -v "Gummitch reinstall" /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Music"
echo "*"
cp --backup=simple -r -u -v ~/Music /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Pictures"
echo "*"
cp --backup=simple -r -u -v ~/Pictures /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Public"
echo "*"
cp --backup=simple -r -u -v ~/Public /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Templates"
echo "*"
cp --backup=simple -r -u -v ~/Templates /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "Videos"
echo "*"
cp --backup=simple -r -u -v ~/Videos /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "VirtualBox stuff"
echo "*"
cp --backup=simple -r -u -v "VirtualBox stuff" /media/tplink-drive/David
echo "*"
echo "************************************************************************"
echo "VirtualBox VMS"
echo "*"
cp --backup=simple -r -u -v "VirtualBox VMS" /media/tplink-drive/David
echo "*"
echo "finished"
humphrey@David:~$ ls -l /usr/local/bin/bup
-rwxrwxrwx 1 humphrey humphrey 2294 Jan 12 10:52 /usr/local/bin/bup
humphrey@David:~$

### I don't know who the correct user should be other than myself, i.e. "humphrey" ###

humphrey@David:~$ stat /usr/local/bin/bup #
  File: ‘/usr/local/bin/bup’
  Size: 2294 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 26739574 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/humphrey) Gid: ( 1000/humphrey)
Access: 2016-01-12 10:52:36.146590228 +1100
Modify: 2016-01-12 10:52:28.258551114 +1100
Change: 2016-01-12 10:52:28.310551383 +1100
 Birth: -
humphrey@David:~$ crontab -l
45 19 * * * /usr/local/bin/bup && tail -f /var/mail/humphrey >~/Desktop/bup-log # JOB_ID_1
humphrey@David:~$

Revision history for this message
GauteHope (eg) wrote : Re: [Bug 1532999] Re: cron does not read $PATH or Gnome Schedule doco is insufficient

Ok. It would not work with just 'bup' since cron does not read $PATH.
Also, tail -f /var/mail/humphrey does not clear the previous log so you
would get the same error every time in your log file, even though the
command works correctly. A better way is:

  /usr/local/bin/bup > /path/to/logfile 2>&1

Could you please try that, and see if it works correctly now.

Indeed, using '&&' results in the old log (from the mail) only being copied over
if the first command succeeds.

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :

Yes, it now works as it should. Thanks.

But, my original complaint still stands:

1 - cron does not read $PATH, but should.

2 - Gnome Scedule doco is insufficient.

As a side comment, I do know that coming to Linux incurs a steep learning curve, but what I have seen of it so far tells me that the learning curve would be a lot less steep if it the documentation were to be improved.

Revision history for this message
GauteHope (eg) wrote :

Humphrey van Polanen Petel writes on January 13, 2016 0:35:
> Yes, it now works as it should. Thanks.
>
> But, my original complaint still stands:
>
> 1 - cron does not read $PATH, but should.

There are secuirty reasons and other implementation difficulties for
that, usually it is not a big problem. Anyway, it is a
bug/feature-request for cron.

> 2 - Gnome Scedule doco is insufficient.

Docs can always be better, and adding some additional information on how
cron works could be useful. If you make a patch I would be happy to
review it.

> As a side comment, I do know that coming to Linux incurs a steep
> learning curve, but what I have seen of it so far tells me that the
> learning curve would be a lot less steep if it the documentation were
> to be improved.

Yes, some of it comes from the ancient ways nix works. The command line
is very powerful, but it also offers lots of possibilities for using it
incorrectly. Perhaps some more examples in the docs would help, I hardly
remember anymore if there are any (although it is not the responsibility
of gnome-schedule to teach general linux and shell commands, that would
bloat the docs with irrelevant stuff).

Happy it works. Gaute

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :

re cron -- how do I raise this as a bug/feature request?

re Gnome Scedule doco -- sorry, but writing docs is serious business and I know too little about what is going on

re general doco -- I will just keep plodding along

Anway, thank you, Gaute

Revision history for this message
GauteHope (eg) wrote :

Humphrey van Polanen Petel writes on January 14, 2016 4:20:
> re cron -- how do I raise this as a bug/feature request?

Look for the implementation of cron you are using (dcron?) then search
for them, I do not know, they are completely separete from
gnome-schedule. Maybe google a little about why it is like this first,
because it is likely to be a concious choice.

> re Gnome Scedule doco -- sorry, but writing docs is serious business and
> I know too little about what is going on
>
> re general doco -- I will just keep plodding along
>
> Anway, thank you, Gaute

Sure! There are a bunch of concepts that are unfamiliar in the
beginning, but they are usually consistent along how Linux and friends
work. So once you get started new things will go easier.

- gaute

Revision history for this message
Humphrey van Polanen Petel (hpvpp) wrote :

marked as duplicate of Bug #1534377

please close

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.