Locked out of Raspberry Pi because of crontab - linux

I installed a crontab that runs a python script in sudo on my Raspberry Pi upon reboot. Since installing this crontab, I receive this error whenever I try to ssh into my pi:
Unable to fork: Cannot allocate memory
I think this is because my python script hogs all the RAM on the pi so that it can't start a new ssh session. What can I do to get back into my pi without resetting the SD card?

Try logging into the raspberry pi directly using the console. That may have sufficient memory to log in.
If that fails, then if you have another raspberry pi sd card or linux machine, and a spare sdcard reader, you can mount your faulty sdcard on the other machine, and edit the crontab files directly to remove the crontab.

Related

Create shell script to reboot linux in case of incorrect shutdown

I have Raspbian Jessie 8 running in a Raspberry Pi 3. There are 3 JavaScript services that are automatically started by PM2.
However, if the Raspberry is shutdown incorrectly, e.g., if the energy cable is removed, the services don't start.
They only start automatically if the Raspberry is shutdown properly, e.g., using sudo reboot.
I need a shell script that checks if the Raspberry was incorrectly shutdown and, if it was, to be rebooted using sudo reboot.
I saw here and here how to create a simple reboot script and here how to check if a service is running, but found nothing on how to check for an improper shutdown. Can anyone tell me how?
You can always put your services start in the legacy startup-file /etc/rc.local that is a shell script called as the very last thing in the startup. Make sure its executable.

Raspberry Pi and RetroPie distro plus LCD

I downloaded RetroPie for my RaspberryPi 3 from this link and have been trying to get my 3.5" LCD to work. I downloaded the driver from here as described, but whenever I try and extract it with the "tar xzvf LCD_show_v6_1_3.tar.gz", the file for the Osoyoo LCD I have, around 50 lines are executed and then the Pi crashes. When I restart it, it goes into a kernel panic every time. I've reinstalled my OS multiple times. I cannot download the raspbian distro with the driver because I have been unable to install RetroPie on top of it and have been unable to display it on the LCD.
Install instructions and product:
Please respond if you know how to solve this problem or what you recommend.
Turns out I was not using enough power. The usb cable I used was a spare rather than official cable for the Pi. Not enough voltage to complete the tasks.

SSH into raspberry pi

I have a question regarding SSH. For school assignments, I always write code on my mac then transfer it over on my raspberry pi to make sure it will compile correctly without errors as they are tested on the pi and sometimes when I transfer it has errors.
To avoid hassle of connecting everything to the pi, if I SSH into the pi, then compile my program from my mac, would it use the raspberry pi compiler?
If you are connected vi ssh and issuing the commands in that terminal session, yes, it's going to use the compiler on the pi.
A better option, and more educational, might be to cross-compile the code for the pi on your mac. You can leverage the much greater processing power of the desktop to significantly reduce your compile time.
Cross Compiling on Mac OSX for Raspberry Pi
Yes it would remotely access the host's OS (in your case the RPi) to perform the compilation.
Here is a guide to get you started:
https://www.modmypi.com/blog/remotely-accessing-the-raspberry-pi-via-ssh-console-mode
Also, in case you want a remote desktop connection, on your raspberry pi enter the following command:
sudo apt-get install xrdp
providing you've already updated and upgraded your package libraries ;)
Yes, If you are using ssh and writing code in that terminal session then the code will be compiled in the pi, it is the best way to do so.
Issuing command in the terminal session via SSH (laptop connected with Raspi), compilation will be done at Raspi. PuTTY is a very useful tool for this, you just need to enable SSH at Raspi and input your IP address at PuTTY only! Click to the PuTTY website http://www.putty.org/ and download it.
Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. The best-known example application is for remote login to computer systems by users.
When you connect to any remote system or server via ssh you are using the same system via command prompt. So, if you do any work via SSH the compilation will be done by the remote system.

Executing a Script from Linux to a Mac

Is it possible to execute a script from a linux machine to run on a Mac, using either Python or Bash? I have a raspberry pi with an arduino, when a sensor or an even occurs from the arduino i want to run a script to do something, "ie: run a "say" command" on my mac, any way of doing this? and how would it be done? i would not like to connect the arduino to the mac, since location is an issue, so it has to be done from the raspberrypi
ssh. if your mac runs sshd.
you can
rasbery> ssh $account#$mac_IP $command

Raspberry pi - file blocking startup

I was trying to make some script automatically run on OS start up, but somehow i did it wrong and now i cant even start the OS since the file is blocking it.
Can i recover the OS removing what i did or at least have access to all my files inside my SD card? I've opened it on my laptop and all i have is two repartitions "BOOT" and "RECOVER" but can't find my user folder /home or anything usefull.
What i did:
sudo cp /home/pi/Desktop/test.sh /etc/rc.local
Thanks!
Best get a bootable CD of a linux distro - fedora, ubuntu, any other, it doesn't really matter - boot the CD on your laptop and mount the SD card from there. Windows can't read linux partitions; other linuxes can.

Resources