pootle
Posts: 374
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

ifconfig inside crontab fails on raspbian lite

Wed Apr 22, 2020 12:18 pm

I have put the following in crontab:
@reboot sleep 55; /sbin/ifconfig >>/home/pi/test.log 2> &1
but it disappears without trace - not even an empty file.

I'm on a pi 0 W running raspbian lite

Have I done something silly or is there a real problem here?

I was calling it using subprocess from python, but the app disappears without trace - apparently not even an exception.

epoch1970
Posts: 4993
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: ifconfig inside crontab fails on raspbian lite

Wed Apr 22, 2020 12:31 pm

Code: Select all

pi@red:~ $ /sbin/ifconfig >>/home/pi/test.log 2> &1
-bash: syntax error near unexpected token `&'
pi@red:~ $ /sbin/ifconfig >>/home/pi/test.log 2>&1
pi@red:~ $ head -2 /home/pi/test.log 
bridge0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.255.230  netmask 255.255.0.0  broadcast 172.17.255.255
pi@red:~ $ 
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

pootle
Posts: 374
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: ifconfig inside crontab fails on raspbian lite

Wed Apr 22, 2020 12:41 pm

Ah! thanks for lifting the brainfog. I use shell so rarely it's easy to make silly mistakes.

Return to “General discussion”