[opensuse] cron jobs and paths
Hello, Just found something odd. I added a path for myself and I can run commands from the path, however after setting up a up a cron job, running as me, it can't find the command. Even root has the command in its path. Output below; Output from command sh /home/james/cleanup.sh /home/james/cleanup.sh: line 22: pg_dump: command not found I can run pg_dump from a CLI with out any problems. Any ideas on how I can fix the cron job environment? Thank you in advance. James -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* James D. Parra
Just found something odd. I added a path for myself and I can run commands from the path, however after setting up a up a cron job, running as me, it can't find the command. Even root has the command in its path. Output below;
Output from command sh /home/james/cleanup.sh
/home/james/cleanup.sh: line 22: pg_dump: command not found
I can run pg_dump from a CLI with out any problems. Any ideas on how I can fix the cron job environment?
add the path to your cron job /path/to/pg_dump You remarked earlier that you added/wanted to add paths to yourself and root. For the added paths to be recognized, the environment must be renewed, ie: a new shell, etc. Also, adding paths makes your system slower as these paths add to the scope of searches for executable files. THE simplest solution is to include the path in cron and, if you need the command for yourself, add an alias (only for onesey-twosey type situations). -- Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://counter.li.org -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
James D. Parra pecked at the keyboard and wrote:
Hello,
Just found something odd. I added a path for myself and I can run commands from the path, however after setting up a up a cron job, running as me, it can't find the command. Even root has the command in its path. Output below;
Output from command sh /home/james/cleanup.sh
/home/james/cleanup.sh: line 22: pg_dump: command not found
I can run pg_dump from a CLI with out any problems. Any ideas on how I can fix the cron job environment?
Thank you in advance.
James
It is always best to use absolute paths in a cron command as cron does not use the environment that you get when you log into an interactive session. If the cron command is to run a script you can add a "path=" statement at the beginning of the script. -- Ken Schneider SuSe since Version 5.2, June 1998 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Monday 2008-04-14 at 10:22 -0700, James D. Parra wrote:
Just found something odd. I added a path for myself and I can run commands from the path, however after setting up a up a cron job, running as me, it can't find the command.
Obviously. Cron uses its own path for safety. You should declare absolute paths when calling programs inside cron, or declare the environment vars you need in cron. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIA9iNtTMYHG2NR9URAkFqAJ9Hj9lE+SB09WRomEwfaPZZixMjNQCfcBER kvIB4YyIg5E4K+S0gI0QV0A= =Tyx8 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (4)
-
Carlos E. R.
-
James D. Parra
-
Ken Schneider
-
Patrick Shanahan