Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
trilljester
Dec 7, 2004

The People's Tight End.

rt4 posted:

I've got a lone entry in my root crontab

code:
50 20 * * tue php -f /var/www/vhosts/example.com/httpdocs/cron/program.php
I've checked the path and it's correct. I've run the program using the same command that's in crontab and it works, too.

Why isn't this working? What can I do about it?

Is tue an actual valid entry for a day of the week in crontab? I've always gone on day of the week in numeric format. 0=Sunday, 6=Saturday. Try changing the "tue" to 2 and see if it works.

Adbot
ADBOT LOVES YOU

Rastor
Jun 2, 2001

Just because it's in root's crontab doesn't mean it runs with root's login environment. Is your program making assumptions about environment variables?

spiritual bypass
Feb 19, 2008

Grimey Drawer

Rastor posted:

Just because it's in root's crontab doesn't mean it runs with root's login environment. Is your program making assumptions about environment variables?

Turns out it was kinda related to this. I had tried the exact command, but I had been trying it from the directory where the program resides. I hadn't been keeping logs so I had no idea my program was dying because it required a file from a relative path.

Thanks for the help!

JHVH-1
Jun 28, 2002

rt4 posted:

Turns out it was kinda related to this. I had tried the exact command, but I had been trying it from the directory where the program resides. I hadn't been keeping logs so I had no idea my program was dying because it required a file from a relative path.

Thanks for the help!

Was gonna say. Some scripts will work from a browser, but if you run them with a full path they won't work because of the way they are coded. You can change the cron to to something like this:
50 20 * * tue cd /var/www/vhosts/example.com/httpdocs/cron/ ; php -f program.php

Or run it using lynx/wget instead if it works from a browser.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Adding MAILTO=whatever@example.com at the beginning of a crontab will send the stdout/err to that address (if the host knows how to send emails that is). Use it at work for all our jobs, it's very quick to see if something failed and why.

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

Carthag posted:

Adding MAILTO=whatever@example.com at the beginning of a crontab will send the stdout/err to that address (if the host knows how to send emails that is). Use it at work for all our jobs, it's very quick to see if something failed and why.

Without that it will send to the user the cronjob runs on, which depending on your environment might be nothing.

Semper Fudge
Feb 19, 2009

Pitchfork was wrong. (f)lowers of Algerbong is crap.
After using Windows for practically all my life, but I finally made the switch to Linux after XP finally crapped out on me. I installed Linux Mint 8, and so far it's been running like a dream. There is one problem though, my wireless network does not seem to show up at all in the wireless list. About 10 of my neighbor's connections seems to show up just fine, so it doesn't appear to be my adapter at fault. My laptop detects my connection just fine, and I know it's not configured to hidden, so I really can't tell what's up with it right now.

It seems to be a semi-common occurence as I read a few threads about it on google, but no one seemed to come up with any solutions. Anyone here know?

HFX
Nov 29, 2004

Rastor posted:

Just because it's in root's crontab doesn't mean it runs with root's login environment. Is your program making assumptions about environment variables?

I often run the command as part of an `su -` option exactly for this reason.

Hydraulic Edwardian
Sep 18, 2008

The fucks I do not give could power the average British household for a decade.
Dumbass Linux newbie question:

I love the cp command. It's retard powerful and no text command has any business being this useful. I've started using cp -Ru to backup all my documents to my Dropbox folder and my external HDD. I've set up an alias so that I can just type backup_docs into terminal and watch my backups get neatly archived. However, I still have to do this manually.

I know there is a way to get BASH to automatically execute commands on login/logout. My goal is to get cp -Ru ~/Documents etc. to execute every time I end a user session, so that if the unthinkable happens I always have a current backup.

Anyone know what the best way to do this is?

edit: Running Xubuntu 9.10 Karmic Koala

Hydraulic Edwardian fucked around with this message at 16:46 on Mar 31, 2010

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Hydraulic Edwardian posted:

Dumbass Linux newbie question:

I love the cp command. It's retard powerful and no text command has any business being this useful. I've started using cp -Ru to backup all my documents to my Dropbox folder and my external HDD. I've set up an alias so that I can just type backup_docs into terminal and watch my backups get neatly archived. However, I still have to do this manually.

I know there is a way to get BASH to automatically execute commands on login/logout. My goal is to get cp -Ru ~/Documents etc. to execute every time I end a user session, so that if the unthinkable happens I always have a current backup.

Anyone know what the best way to do this is?

edit: Running Xubuntu 9.10 Karmic Koala

.bashrc contains the startup commands

You might want to look into tar (and compressing them), instead of cp'ing everything

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

Hydraulic Edwardian posted:

Dumbass Linux newbie question:

I love the cp command. It's retard powerful and no text command has any business being this useful. I've started using cp -Ru to backup all my documents to my Dropbox folder and my external HDD. I've set up an alias so that I can just type backup_docs into terminal and watch my backups get neatly archived. However, I still have to do this manually.

I know there is a way to get BASH to automatically execute commands on login/logout. My goal is to get cp -Ru ~/Documents etc. to execute every time I end a user session, so that if the unthinkable happens I always have a current backup.

Anyone know what the best way to do this is?

edit: Running Xubuntu 9.10 Karmic Koala

I think something like .bash_login and .bash_logout (just read the man page, those are correct) get exectued at login and logout.

And for maximum mind blowing, checkout rsync. You should just be able to replace the 'cp' part of your command with 'rsync' and everything will keep on working. Except it will run a hash on the files on both sides and only copy stuff that has changed, saving yourself a nice chunk of time.

Hydraulic Edwardian
Sep 18, 2008

The fucks I do not give could power the average British household for a decade.

Bob Morales posted:

.bashrc contains the startup commands

You might want to look into tar (and compressing them), instead of cp'ing everything

Thanks. I will. Right now my documents folder is pretty small, so I can afford to just raw cp it. Once I start working on backing up my Music and such I'll get on that.

Would putting a command in .bash_logout also work?

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

Hydraulic Edwardian posted:

Thanks. I will. Right now my documents folder is pretty small, so I can afford to just raw cp it. Once I start working on backing up my Music and such I'll get on that.

Would putting a command in .bash_logout also work?

The whole thing about .bashrc and .bash_login (and .profile) is a little confusing:

man bash posted:

When bash is invoked as an interactive login shell, or as a non-inter‐ctive shell with the --login option, it first reads and executes com‐mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from thefile ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

So when you login to the GUI, or SSH in, That's a login shell: .bash_profile, .bash_login, or .profile is executed, whichever it finds first. And when your GUI or SSH session ends, .bash_logout is executed. If you open a terminal from within your GUI enviroment, or I suppose launch an xterm from your SSH session, that's an interactive session. In that case, .bashrc is read.

The way Ubuntu (and I assume Xubuntu) does it by default is it creates .profile and .bashrc, all the good stuff goes in .bashrc, and .profile just executes .bashrc (and also puts ~/bin in your path). I think you would want to put your backup command in .bash_logout, since it makes sense that you'd want to backup on exit.

Rastor
Jun 2, 2001

No seriously, rsync is what you should be using for this. Go get yourself some rsync.

Hydraulic Edwardian
Sep 18, 2008

The fucks I do not give could power the average British household for a decade.
But but but using the terminal makes me feel so DIY and special.

HFX
Nov 29, 2004

Hydraulic Edwardian posted:

But but but using the terminal makes me feel so DIY and special.

rsync is a terminal command.

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

HFX posted:

rsync is a terminal command.

Yeah, and about a zillion times more powerful than cp. Just try replacing the 'cp' in your alias with 'rsync' and see how that goes for you.

trilljester
Dec 7, 2004

The People's Tight End.

Rastor posted:

No seriously, rsync is what you should be using for this. Go get yourself some rsync.

This.

rsync -a <source>/ <dest>/

The trailing slashes are useful.

Lukano
Apr 28, 2003

I'm using the Ubuntu 10.04 beta, and am having a headache with the built in Gnome Remote Desktop (vino). I can connect to the server via ssh tunnel, or direct if I open the ports - but beyond that, I get nothing. It takes my password, then does not even begin to draw the screen or provide dimensions to the client.

I know there's been issues with vino and certain xorg drivers (nvidia) that are resolved by disabling desktop effects, compiz, and using noxdamage when/where possible. I've tried the first two, and can't figure out how to try the third without physical access to the machine.

Any ideas or suggestions?

spiritual bypass
Feb 19, 2008

Grimey Drawer
My suggestion is to forget about VNC and use NX. It's the fastest remote desktop thing I've ever used. In fact, I'm posting from it right now.

If you already have a working sshd, then all you need to do is install the Ubuntu packages from nomachine.com and it's ready to go.

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

rt4 posted:

My suggestion is to forget about VNC and use NX. It's the fastest remote desktop thing I've ever used. In fact, I'm posting from it right now.

If you already have a working sshd, then all you need to do is install the Ubuntu packages from nomachine.com and it's ready to go.

Yep, it is basically awesome.

I've got it setup on my server to start a session on boot of the machine. It's a bit of a hack, but I can post the script if you're interested.

spiritual bypass
Feb 19, 2008

Grimey Drawer

FISHMANPET posted:

I've got it setup on my server to start a session on boot of the machine. It's a bit of a hack, but I can post the script if you're interested.

Why do you start an NX session on boot? Couldn't you just start whatever session you want when you connect?

crazysim
May 23, 2004
I AM SOOOOO GAY

FISHMANPET posted:

Yep, it is basically awesome.

I've got it setup on my server to start a session on boot of the machine. It's a bit of a hack, but I can post the script if you're interested.

I'm interested in this script!

Lukano
Apr 28, 2003

Can you hook the NX session in to the existing desktop session locally (like Remote Desktop does) or does it require it's own unique X session ala; x11vnc or vnc4server?

spiritual bypass
Feb 19, 2008

Grimey Drawer

Lukano posted:

Can you hook the NX session in to the existing desktop session locally (like Remote Desktop does) or does it require it's own unique X session ala; x11vnc or vnc4server?

Your local session can be connected to in the "shadow" mode, but you need to be root to do it, even if you're logged in as a normal user.

nbv4
Aug 21, 2002

by Duchess Gummybuns
Here is my script

code:
#! /bin/bash

cd /srv/site

#execute script to make a backup on remote site
ssh chris@mydomain.com "/srv/site/make-fixtures";

# copy remote dump to the local project dir
scp chris@mydomain.com:/srv/site/dump .;

exit
It works fine if I run it manually, but from within a cron job, it fails. The problem is that the ssh and scp commands rely on my rsa key to work correctly, which isn't a problem for me at my shell, but from within a cron job, it fails. What do I need to do to make it work?

nbv4 fucked around with this message at 21:01 on Apr 1, 2010

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

nbv4 posted:

It works fine if I run it manually, but from within a cron job, it fails. The problem is that the ssh and scp commands rely on my rsa key to work correctly, which isn't a problem for me at my shell, but from within a cron job, it fails. What do I need to do to make it work?

http://support.svi.nl/wiki/ScpBatchMode

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

rt4 posted:

Why do you start an NX session on boot? Couldn't you just start whatever session you want when you connect?

I have GUI programs that I want started at boot.

And here's how I did it:
http://ubuntuforums.org/showthread.php?t=1034807
(that's not me)

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:03 on Mar 13, 2017

covener
Jan 10, 2004

You know, for kids!

GregNorc posted:

Cross posting this in the linux thread, trying to get some opinions.

I'm getting a new thinkpad and trying to pick a distro... narrowed it down to three:

Ubuntu
CentOS
FreeBSD (yes I realize BSD != Linux but they're so similar I'm gonna lump them together anyways :colbert:)



No sense/joy in centos/RHEL as a desktop. Suggest simply ubuntu for the desktop experience on your thinkpad + virtualization for anything else.

IanMalcolm
Jan 22, 2010

GregNorc posted:

Cross posting this in the linux thread, trying to get some opinions.

I'm getting a new thinkpad and trying to pick a distro... narrowed it down to three:

Ubuntu
CentOS
FreeBSD (yes I realize BSD != Linux but they're so similar I'm gonna lump them together anyways :colbert:)

I was hoping to get some opinions on what's the best of the three for my purposes (security geek, so FreeBSD appeals in that egard, but also busy as hell so out of the box functionality and sheer amount of documentation makes Ubuntu a strong candidate. CentOS seems like it might be a decent middle ground - enough businesses using Redhat to make it stable and have good documentation, but a bit more streamlined than say, Ubuntu.)

Thoughts?

If you are considering FreeBSD, you might as well take a look at Gentoo.
It all depends on how much headache you want. Ubuntu is pretty good until you get sick of all the morons in the community.

nbv4
Aug 21, 2002

by Duchess Gummybuns

hmm that doesn't work.

here is my script now:

code:
#! /bin/bash

cd /srv/site

#execute script to make a backup on remote site
ssh chris@mydomain.com "/srv/site/make-fixtures";

echo "after ssh";

# copy remote dump to the local project dir
scp -B chris@mydomain.com:/srv/site/dump .;

echo "after scp";

exit
I get this output:

code:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
after ssh
Permission denied (publickey,password).
after scp

covener
Jan 10, 2004

You know, for kids!

nbv4 posted:

hmm that doesn't work.

here is my script now:

code:
#! /bin/bash

cd /srv/site

#execute script to make a backup on remote site
ssh [email]chris@mydomain.com[/email] "/srv/site/make-fixtures";

echo "after ssh";

# copy remote dump to the local project dir
scp -B [email]chris@mydomain.com[/email]:/srv/site/dump .;

echo "after scp";

exit
I get this output:

code:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
after ssh
Permission denied (publickey,password).
after scp

when you're running under cron, you don't have an ssh-agent to connect to, so you're being prompted for your key or remote system password.

Lukano
Apr 28, 2003

GregNorc posted:

Cross posting this in the linux thread, trying to get some opinions.

I'm getting a new thinkpad and trying to pick a distro... narrowed it down to three:

Ubuntu
CentOS
FreeBSD (yes I realize BSD != Linux but they're so similar I'm gonna lump them together anyways :colbert:)

I was hoping to get some opinions on what's the best of the three for my purposes (security geek, so FreeBSD appeals in that egard, but also busy as hell so out of the box functionality and sheer amount of documentation makes Ubuntu a strong candidate. CentOS seems like it might be a decent middle ground - enough businesses using Redhat to make it stable and have good documentation, but a bit more streamlined than say, Ubuntu.)

Thoughts?

I'd suggest Ubuntu as well. You can go feral and switch over to Gentoo or Slackware later, but if you're just getting started - it'll be the easiest transition from Windows. A wealth of online resources, and it's just easy and works.

Red Robin Hood
Jun 24, 2008


Buglord
I'm running Fedora 12 and have limited linux knowledge. How do I get gkrellm to start on boot? Can I use add startup program? If so, what command do I enter?

enotnert
Jun 10, 2005

Only women bleed

Anphrax posted:

I'm running Fedora 12 and have limited linux knowledge. How do I get gkrellm to start on boot? Can I use add startup program? If so, what command do I enter?

Easiest way for someone relatively new to do it, is make sure it's running, and when logging out make sure you have "save session" clicked (I haven't used fedora 12, I know in previous fedoras it was actually in one of the settings under system-preferences or something). Log out, log back in, then uncheck the save session.

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:00 on Mar 13, 2017

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams

enotnert posted:

Easiest way for someone relatively new to do it, is make sure it's running, and when logging out make sure you have "save session" clicked (I haven't used fedora 12, I know in previous fedoras it was actually in one of the settings under system-preferences or something). Log out, log back in, then uncheck the save session.

That's kind of a dirty hack. I think you can specify programs that get run when you login. I don't think you actually want that to run at login, not start up. Having a GUI problem run at boot doesn't make any sense, because at boot there's no GUI to put it in.

NOTinuyasha
Oct 17, 2006

 
The Great Twist

IanMalcolm posted:

If you are considering FreeBSD, you might as well take a look at Gentoo.
It all depends on how much headache you want. Ubuntu is pretty good until you get sick of all the morons in the community.

Migrating to Gentoo to get away from morons is like running to Auschwitz to escape from the Nazis

GregNorc posted:

So I'm basically looking for something that's the best balance between "relatively simple to set up" and supporting more advanced users. Right now I've narrow it to two choices... I'm debating between Ubuntu and FreeBSD.

I think the documentation for Ubuntu is way better especially if you're working with obscure stuff, bleeding edge features like NTFS-3G works very well and there are a lot of useful scripts in the official repositories, for example a usb automounter that I worked with a while back. Out-of-the-box support for full disk encryption, all sorts services it can pull right from the installer, great hardware support, I think it seals the deal. I really like the headless edition, lightweight and a great way to learn without being coddled by any sort of GUI.

Adbot
ADBOT LOVES YOU

Red Robin Hood
Jun 24, 2008


Buglord

enotnert posted:

Easiest way for someone relatively new to do it, is make sure it's running, and when logging out make sure you have "save session" clicked (I haven't used fedora 12, I know in previous fedoras it was actually in one of the settings under system-preferences or something). Log out, log back in, then uncheck the save session.

I suppose I didn't really explain myself well enough. I installed Fedora to learn linux, I have no problem solving my issue the hard way; care to explain more in-depth?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply