简体   繁体   English

在树莓派上启动期间未找到 Bash 别名

[英]Bash alias not found during start-up on raspberry pi

I am trying to get a simple script to run on start-up of debian Raspberry Pi where startupTest.py writes the time of run to a.txt file我试图让一个简单的脚本在 debian Raspberry Pi 启动时运行,其中startupTest.py将运行时间写入 a.txt 文件

$python3 /home/pi/startupTest.py runs successfully in command line $python3 /home/pi/startupTest.py在命令行中运行成功

$ python /home/pi/startupTest.py runs successfully in command line $ python /home/pi/startupTest.py在命令行中运行成功

However using $ sudo crontab -e to write @reboot python3 /home/pi/startupTest.py &但是使用$ sudo crontab -e编写@reboot python3 /home/pi/startupTest.py &

Yields产量

bash: alias: python: not found

bash: alias: /usr/local/bin/python3.8: not found

bash: alias: python: not found

bash: alias: /usr/local/bin/python3.8: not found

bash: alias: python: not found

bash: alias: /usr/local/bin/python3.8: not found

Okay, am I missing python3.8 in that directory?好的,我在那个目录中缺少 python3.8 吗? no

$ ls /usr/local/bin shows python3.8 $ ls /usr/local/bin显示 python3.8

I am a Mechanical Engineering student trying to get a testing system working for my senior design project.我是一名机械工程专业的学生,试图让一个测试系统为我的高级设计项目工作。

The problems is when running sudo crontab -e actually that root user runs the script.问题是在运行时sudo crontab -e实际上是 root 用户运行脚本。 If in your startupTest.py you do not have any special code that might need sudo privilege, just remove sudo and add your command in crontab -e startup list.如果在您的startupTest.py中没有任何可能需要sudo权限的特殊代码,只需删除sudo并将您的命令添加到crontab -e启动列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM